G
Ganapathi Hegde
Hi,
I am new to ASP.NET. I developed an sample application, which displays the
database table on DataGrid Control.
I added Edit, Update, Cancel (Button Column) to Grid Control. Then I
implemented EditCommand, CancelCommand and UpdateCommand
When I click on Edit link text box will display for editing the fild. But I
noticed that, in UpdateCommand still I recieve the old va;ue of text box
even if I changed the values.
But this is happening because AutoPostBack property of text box is false.
This text box is created by framework, is there anyway to overcome this
problem.
Code for your refernce :
private void Grid1_Edit(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) -- EditCommand
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
UpdateData();
}
private void Grid1_Update(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) - UpdateCommand
{
TextBox tb1 = (TextBox) e.Item.Cells[1].Controls[0];
DataRow dr ;
dr = this.ds.Tables[0].Rows[e.Item.ItemIndex];
dr["Test_Case"] = "Test Case2";
try
{
this.adapter.Update(this.ds,"tTestCase");
}
catch(Exception ex)
{
sz = ex.ToString();
}
DataGrid1.EditItemIndex = -1;
UpdateData();
}
private void Grid1_Cancel(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) - CancelCommand
{
DataGrid1.EditItemIndex = -1;
UpdateData();
}
I am new to ASP.NET. I developed an sample application, which displays the
database table on DataGrid Control.
I added Edit, Update, Cancel (Button Column) to Grid Control. Then I
implemented EditCommand, CancelCommand and UpdateCommand
When I click on Edit link text box will display for editing the fild. But I
noticed that, in UpdateCommand still I recieve the old va;ue of text box
even if I changed the values.
But this is happening because AutoPostBack property of text box is false.
This text box is created by framework, is there anyway to overcome this
problem.
Code for your refernce :
private void Grid1_Edit(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) -- EditCommand
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
UpdateData();
}
private void Grid1_Update(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) - UpdateCommand
{
TextBox tb1 = (TextBox) e.Item.Cells[1].Controls[0];
DataRow dr ;
dr = this.ds.Tables[0].Rows[e.Item.ItemIndex];
dr["Test_Case"] = "Test Case2";
try
{
this.adapter.Update(this.ds,"tTestCase");
}
catch(Exception ex)
{
sz = ex.ToString();
}
DataGrid1.EditItemIndex = -1;
UpdateData();
}
private void Grid1_Cancel(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) - CancelCommand
{
DataGrid1.EditItemIndex = -1;
UpdateData();
}