|
Subject:
|
Update Button in DataGrid
|
|
Posted By:
|
Bibin
|
Post Date:
|
1/12/2006 3:30:47 PM
|
Hi, Im a new member of Wrox. I need a help. I want to update my records through DataGrid The problem is while using the Textbox control I cannot retrieve the New values inputted by me. Plz. help me as soon as possible. If possible plz. also mail me to bibin_austin@yahoo.com
|
|
Reply By:
|
sands.msk
|
Reply Date:
|
1/28/2006 7:22:44 AM
|
hai bibin i think you are just started using the datagrid. from the posting nobody can recognise what the real proble is. Any way u can use the asptemplate coloumn
<asp:TemplateColumn HeaderText="Name"> <ItemTemplate> <asp:TextBox id="txtName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>' /> </ItemTemplate> </asp:TemplateColumn>
use these codes in ur datagrid "Name" is the field in table to update.
int update function
suppose
void btnUpdate_click(Object sender, EventArgs e) { string strName = ""; for (int i=0; i<MyDataGrid.Items.Count; i++) { DataGridItem _item = MyDataGrid.Items[i]; TextBox txtName = (TextBox)_item.FindControl("txtName"); strName = txtName.Text.toString().Tirm(); //here you can write the query to update the database
} // after updation bind the grid again BindGrid(); }
|