c# - looping through gridview does not always work -


Not sure why I tried some suggestions that no one would help. I've sometimes debug my application several times and this problem never happens when everything is properly debug. But when I publish my application and allow people to use it, then the problem is and this is not for everyone, it only randomly decides that the checkbox is not checked And leaves the whole process even further at the end. Before checking a checkbox, button_click will fire, so I know that they have to check one.

Gridview

  & lt; Div id = "divEventDetail" & gt; & Lt; Asp: GridView id = "grdEventDetail" runat = "server" autoogenerate column = "false" datakiname = "idid" width = "381px" annuitydatabase = "grdEventDetail_RowDataBound" gridline = "horizontal" & gt; & Lt; Columns & gt; & Lt; Asp: TemplateField HeaderText = "EventID" visible = "false" & gt; & Lt; ItemTemplate & gt; & Lt; Asp: label id = "lblEventID" runat = "server" text = '& lt;% # Eval ("EDID")% & gt; & Gt; & Lt; / Asp: label & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; ASP: TemplateField HeaderText = "Register" ItemSystem - CssClass = "template-center" & gt; & Lt; Itemmetlet & gt; & Lt; Asp: checkbox id = "chkRegister" runat = "server" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; Asp: TemplateField HeaderText = "Waitlisted" ItemSystem - CssClass = "template-center" & gt; & Lt; ItemTemplate & gt; & Lt; Asp: check box id = "chkWaitList" runat = "server" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt; & Lt; / Div & gt;  

CodeBehind

  Secure void registerEvent () {foreach (GridViewRow line in grdEventDetail.Rows) {checkbox chkR = row.FindControl ("chkRegister") Check box in form; Checkbox chkW = row.FindControl ("chkWaitList") as checkbox; If (chkR! = Null & amp;; chkW! = Null) // This is a datarow {GridViewRow Rowr = ((GridViewRow) chkR.Parent.Parent); Gridviewer Row = (gridviewer) chkW.Parent.Parent); If ((chkR.Checked)) // if (((((checkbox) line control ("chkRegister"). Czech == true) || ((checkbox) row.FindControl ("ChkWaitList "). Checked == true)) {Label eventID = row.FindControl (" lblEventID ") as label; *** Then I can do my database stuff here  

I believe that in grdEventDetail GridView in each line There is no checkbox for example, headerr and footerrow probably not those checkboxes

I To eliminate any errors, I type the code again:

  secure void registerEvent () {foreach (GridViewRow line in grdEventDetail.Rows) {checkbox chkR = row.FindControl ("ChkRegister Check box as checkbox chkW = row.FindControl ("chkWaitList") checkbox; if (chkR! = Null & amp; amp; chkW! = Null) // This is a datarow {GridViewRow Rowr = ( (GridViewRow) chkR.Parent.Parent; Gridviewer Row = (gridviewer) chkW.Parent.Parent); If ((chkR.Checked)) ({chkW.Checked)} {// your code goes here}}}}  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -