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,
The event was not firing due to the way you are trying to set the template. I am attaching the modified sample with the event firing. It is not possible to have the row index in the click event which is defined in class in which this control is not defined. I have modified the InitializeRow event to keep the row index and when the ItemCommand you can get the index of the selected row. This is the reccomended approach for ASP.
Hi NikiforSorry for the delayed answer.Attached I send you a sample solution.In the code behind, the button_click should be called whena button is clicked. I should also get the current row there.Thanks a lot for a quick answer.RegardsFrankby the way: 200kb for attachment is not very much :-)Had to delete ig_res
Hello Frank,Please let me know if you have any further questions regarding this issue.
Hello Frank,I have tested the sample again with IE 9, Chrome, FF 10 under Win 7 64 bit. All the browsers act the same. I am able to enter in the event when the button is pressed. The page makes postback and after this the grid is with the same data – no rows are cleared. Please confirm that you are facing the behavior in the sample. If so please confirm that your version is still 11.2.20112.2025 and you have not upgraded to a new one (I tested it with 11.2.20112.2086 too). Please in future do not paste your code but attach it in *.zip files to every forum post
Hi NikiforNo, it still does not work ...I can press the button without getting a exception,but the event is not raised ... and after pressing thebutton, the grid is empty ...
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();";
_Button_Cancel.Click +=
(button_Click);
container.Controls.Add(_Button_Cancel);
}
e)