G
Guest
Hi
I've been following the example on
http://aspnet.4guysfromrolla.com/articles/071002-1.3.aspx
and no matter what I do, i can't get the DataGrid1_EditCommand event handler
to fire. Could someone please tell me what I'm doing wrong.
Code below.
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
private void Page_Load(object sender, System.EventArgs e)
{
using(SqlCommand cmd = new SqlCommand("select * from SystemInfo",
sqlConnection1))
using(SqlDataAdapter da = new SqlDataAdapter(cmd))
{
sqlConnection1.Open();
DataTable dt = new DataTable();
da.Fill(dt);
DataGrid1.DataSource=dt;
DataGrid1.DataBind();
}
}
public void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}
....
<form id="Form1" method="post" runat="server">
<aspataGrid Runat="server" ID="DataGrid1" AutoGenerateColumns="False"
OnEditCommand="DataGrid1_EditCommand">
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" CancelText="Cancel"
EditText="Edit" UpdateText="Update" />
<asp:BoundColumn ReadOnly="False" DataField="Measure"/>
</Columns>
</aspataGrid>
</form>
I've been following the example on
http://aspnet.4guysfromrolla.com/articles/071002-1.3.aspx
and no matter what I do, i can't get the DataGrid1_EditCommand event handler
to fire. Could someone please tell me what I'm doing wrong.
Code below.
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
private void Page_Load(object sender, System.EventArgs e)
{
using(SqlCommand cmd = new SqlCommand("select * from SystemInfo",
sqlConnection1))
using(SqlDataAdapter da = new SqlDataAdapter(cmd))
{
sqlConnection1.Open();
DataTable dt = new DataTable();
da.Fill(dt);
DataGrid1.DataSource=dt;
DataGrid1.DataBind();
}
}
public void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}
....
<form id="Form1" method="post" runat="server">
<aspataGrid Runat="server" ID="DataGrid1" AutoGenerateColumns="False"
OnEditCommand="DataGrid1_EditCommand">
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" CancelText="Cancel"
EditText="Edit" UpdateText="Update" />
<asp:BoundColumn ReadOnly="False" DataField="Measure"/>
</Columns>
</aspataGrid>
</form>