c# - Find checkbox control in ASPxGridView -
I have an aspxGridView containing a checkbox dataTemplate that has GridVidgetteCalom. Now I have to find that control for every line and check / uncheck / check on runtime.
Here is my code for ASPxGridView:
& lt; Dx: ASPxGridView id = "RadGrid2" runat = "server" auto generated column = "false" client name = "grid" keyfieldname = "store_id" settingspager-mode = "all alerts" width = "50%" & gt; & Lt; Show settingsVersical ScrollBar = "true" /> & Lt; Columns & gt; & Lt; Dx: GridViewDataCheckColumn caption = "#" visible index = "0" width = "25%" & gt; & Lt; DataItemTemplate & gt; & Lt; dx: ASPxCheckBox ID = "checkbox 1" run = "server" & gt; & Lt; / dx: ASPxCheckBox & gt; & Lt; / DataItemTemplate & gt; & Lt; / dx: GridViewDataCheckColumn & gt; & Lt; Dx: GridViewDataTextColumn field name = "STORE_NAME" caption = "store name" readonly = "true" visible index = "1" width = "75%" & gt; & Lt; EditFormSettings visible = "false" /> & Lt; / dx: GridViewDataTextColumn & gt; & Lt; / Column & gt; & Lt; / dx: ASPxGridView & gt; This is my code to run each row again and get control. {Checkbox chk = RadGrid2.FindRowTemplateControl (i, "checkbox 1") for
(int i = 0; i & lt; radgrid2.visibleRowCount; i ++) checkbox; chk.Checked = false; } I'm getting a tap reference exception, so I think it can not control and I'm doing it wrong. any idea? Thanks!
You are using the wrong method that searches the specific server control specified within specified data . / P>
You should use the method to find the column's dynamite template container or control in the specified data.
Please also refer to the topic
References:
Comments
Post a Comment