Answered by:
Grideview

Question
-
User674443648 posted
Grideview Bounded fill
How can update Grideview Colomn in DataBound COntrol
IF you click edit link than after two textbox is showing but two textbox how can find
plz send soluton
Tuesday, October 18, 2011 4:22 AM
Answers
-
User-448512826 posted
Hi,
in row Updating event you can get those control which is in Edit template of that griview..like....
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName"); DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender"); TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity"); DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType"); customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(),txtName.Text, cmbGender.SelectedValue,txtCity.Text, cmbType.SelectedValue); GridView1.EditIndex = -1; FillCustomerInGrid(); }
check below link for details..
http://www.aspdotnetcodes.com/GridView_Insert_Edit_Update_Delete.aspx
http://forums.asp.net/t/1367935.aspx/1
Thanks...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 18, 2011 4:44 AM
All replies
-
User-1673382244 posted
hi
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowupdating.aspx
Tuesday, October 18, 2011 4:26 AM -
User-448512826 posted
Hi,
in row Updating event you can get those control which is in Edit template of that griview..like....
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName"); DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender"); TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity"); DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType"); customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(),txtName.Text, cmbGender.SelectedValue,txtCity.Text, cmbType.SelectedValue); GridView1.EditIndex = -1; FillCustomerInGrid(); }
check below link for details..
http://www.aspdotnetcodes.com/GridView_Insert_Edit_Update_Delete.aspx
http://forums.asp.net/t/1367935.aspx/1
Thanks...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 18, 2011 4:44 AM -
User-1782291982 posted
GridView design code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false"
AutoGenerateEditButton ="true" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating">
<Columns>
<asp:BoundField DataField ="ID" HeaderText ="ID" />
<asp:BoundField DataField ="Title" HeaderText ="Title" />
<asp:BoundField DataField ="Phoneno" HeaderText ="ReleaseDate" />
<asp:BoundField DataField ="EmailID" HeaderText ="Price(Rs)" />
</Columns>
</asp:GridView>GridView Code BEhind Code
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);
string title = GridView1.Rows[e.RowIndex].Cells[2].Text;
string Phoneno = GridView1.Rows[e.RowIndex].Cells[3].Text;
string EmailID = GridView1.Rows[e.RowIndex].Cells[4].Text;
SqlConnection cnn = new SqlConnection();
cnn.Open();
SqlCommand cmd = new SqlCommand("update employee set title ='" + title + "' where id ='" + id + "'", cnn);
cmd.ExecuteNonQuery();
cnn.Close();
}Tuesday, October 18, 2011 6:55 AM -
Tuesday, October 18, 2011 7:02 AM
-
User-1230503176 posted
It will definately help you.
http://howtouseasp.net/how-to-use-gridview-with-databound-fields-ado-net-way-c/
with regards
vik
Thursday, October 20, 2011 5:25 AM