Hi allI have a WebDataGrid, I fill it in .aspx.ch like ".DataSource = SomeDataTable".The last column is empty and I like to have a button there on each row.OnClick I need to read some informations about the current row.I guess this should be done with TemplateDataField.How can I do this in the code behind after setting the DataSource ?Thanks and best regardsFrank Uray
Hello Frank,Please let me know if you have any further questions regarding this issue.
Hello Frank,This is the modified sample. You have the event += to the button and at the moment when you press the button you get an exception. Please modify the body of the function to match your goals. Please also take a note that this event is outside the page so you dont have access to the controls.
Hi NikiforI have seen this, but I need the event raised in the C# CodeBehind.Thanks and regardsFrank Uray
Hello Frank,In the attached from me sample there are client side even onClick handled. The javascript function should be named with the default name which is given when you add this event from the designer. When the javascript function is named like “myJavaScriptHandler” some of the browsers may not handle it. Please look at the attached sample how I have added the function in the client and set it to the button in the code behind.
Hello NikiforI have tried also with your javascript function,but this also does not work ...I also tried this, but also does not work,I get Javascript exception "Microsoft JScript runtime error: Object expected": <script type="text/C#" runat="server"> void Button_Cancel_Click(object sender, EventArgs e) { System.Windows.Forms.MessageBox.Show("Test"); } </script> public void InstantiateIn(System.Web.UI.Control container) { System.Web.UI.WebControls.Button _Button_Cancel = new System.Web.UI.WebControls.Button(); _Button_Cancel.Height = 25; _Button_Cancel.Width = 60; _Button_Cancel.Text = "Cancel"; _Button_Cancel.OnClientClick = "Button_Cancel_Click();"; container.Controls.Add(_Button_Cancel); }
RegardsFrank