Buttons in DataGrid not working
-
Hi, I am creating a datagrid with a column of buttons. I thought I set it up so that when a button is pushed the DataGrid1_ItemCommand is called, but for some reason it is not working. Here is my html code: And here is my server code: public void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Label2.Text = "asdfasedfasdf"; } Similar code works on other pages. Am I missing something? Thanks, RC
-
Hi, I am creating a datagrid with a column of buttons. I thought I set it up so that when a button is pushed the DataGrid1_ItemCommand is called, but for some reason it is not working. Here is my html code: And here is my server code: public void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Label2.Text = "asdfasedfasdf"; } Similar code works on other pages. Am I missing something? Thanks, RC
Hi RC, If you're using VS.NET and CodeBehind, make sure you still have the following in your Initialize Component code: this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand); Datagrid Girl http://www.datagridgirl.com http://www.codeproject.com
-
Hi RC, If you're using VS.NET and CodeBehind, make sure you still have the following in your Initialize Component code: this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand); Datagrid Girl http://www.datagridgirl.com http://www.codeproject.com
That code is already in the InitializeComponent() method. But it still doesn't work.
-
That code is already in the InitializeComponent() method. But it still doesn't work.
The other thing to check is whether you're re-Databinding the grid in the Page Load event without checking IsPostBack, that would prevent your other events from firing. Datagrid Girl http://www.codeproject.com
-
The other thing to check is whether you're re-Databinding the grid in the Page Load event without checking IsPostBack, that would prevent your other events from firing. Datagrid Girl http://www.codeproject.com
That was it. I was re-binding the datagrid in the Page_Load. Thanks for your help!! RC