c# - Clicking Update in the EditCommandColumn of an ASP.NET DataGrid does not initiate the Click event defined in codebehind -


i have datagrid receives data several tables in entity data model.i used editcommandcolumn provide editing of data templatecolumns bound columns of function import stored procedure on database.

here portion of .aspx code creation of asp:datagrid

<asp:updatepanel id="gridupdate" runat="server" updatemode="conditional">     <contenttemplate>         <div style="vertical-align: top; height:250px; overflow:auto; width:1800px;">             <asp:datagrid id="dgdeditq" runat="server" allowpaging="true" allowsorting="true"                      backcolor="antiquewhite" bordercolor="green" borderstyle="ridge"                      cellpadding="10" font-bold="true"                     font-size="large" width="1800px" height="250px" oneditcommand="dgdeditq_edit"                     oncancelcommand="dgdeditq_cancel" onupdatecommand="dgdeditq_update"                     cellspacing="10" viewstatemode="disabled" itemstyle-wrap="false"                      itemstyle-width="100" autogeneratecolumns="false">                  <alternatingitemstyle />                 <columns>                     <asp:editcommandcolumn                             edittext="edit"                             canceltext="cancel"                             updatetext="update"                             headertext="edit item"                             buttontype="linkbutton">                     </asp:editcommandcolumn>                      <asp:templatecolumn visible="true">                         <headertemplate>                             <b> quote number </b>                         </headertemplate>                            <itemtemplate>                             <asp:label  runat="server" text='<%#eval("quotenumber") %>'></asp:label>                         </itemtemplate>                                                                               </asp:templatecolumn>                      <asp:templatecolumn visible="false">                         <headertemplate>                             <b> name </b>                         </headertemplate>                            <itemtemplate>                             <asp:label id="lbledn"  runat="server" text='<%#eval("name") %>'></asp:label>                         </itemtemplate>                         <edititemtemplate>                             <asp:textbox runat="server" text='<%#eval("name") %>' id="txbedname" maxlength="50"></asp:textbox>                             <asp:requiredfieldvalidator id="rfvname" runat="server" controltovalidate="txbedname" errormessage="the name of quote required."></asp:requiredfieldvalidator>                         </edititemtemplate>                                                                               </asp:templatecolumn>                      <asp:templatecolumn visible="false">                     <headertemplate>                         <b> street </b>                     </headertemplate>                        <itemtemplate>                         <asp:label id="lbledst"  runat="server" text='<%#eval("street") %>'></asp:label>                     </itemtemplate>                     <edititemtemplate>                         <asp:textbox runat="server" text='<%#eval("street") %>' id="txbedstreet" maxlength="50"></asp:textbox>                     </edititemtemplate>                                                                               </asp:templatecolumn>                      <asp:templatecolumn visible="false">                     <headertemplate>                         <b> city & state </b>                     </headertemplate>                        <itemtemplate>                         <asp:label id="lbledcs"  runat="server" text='<%#eval("citystate") %>'></asp:label>                     </itemtemplate>                     <edititemtemplate>                         <asp:textbox runat="server" text='<%#eval("citystate") %>' id="txbedcs" maxlength="50"></asp:textbox>                     </edititemtemplate>                                                                              </asp:templatecolumn>                  </columns>                 <selecteditemstyle />             </asp:datagrid>         </div>     </contenttemplate> </asp:updatepanel>      

when click edit in editcommandcolumn works everytime , cancel well, update button click never triggers onclick eventhandler in code behind:

protected void dgdeditq_update(object sender, datagridcommandeventargs e)     {         datagriditem dgi = dgdeditq.selecteditem;         textbox[] myboxes = new textbox[26];         string[] myparams = new string[26];          myboxes[0] = (textbox)dgi.findcontrol("quote number");         myboxes[1] = (textbox)dgi.findcontrol("name");         myboxes[2] = (textbox)dgi.findcontrol("street");         myboxes[3] = (textbox)dgi.findcontrol("city & state");         myboxes[4] = (textbox)dgi.findcontrol("type of quote");         myboxes[5] = (textbox)dgi.findcontrol("list provided by");         myboxes[6] = (textbox)dgi.findcontrol("estimator");         myboxes[7] = (textbox)dgi.findcontrol("date received");         myboxes[8] = (textbox)dgi.findcontrol("date due");         myboxes[9] = (textbox)dgi.findcontrol("date of plans");         myboxes[10] = (textbox)dgi.findcontrol("date of revision");         myboxes[11] = (textbox)dgi.findcontrol("revision #");         myboxes[12] = (textbox)dgi.findcontrol("plan name");         myboxes[13] = (textbox)dgi.findcontrol("customer");         myboxes[14] = (textbox)dgi.findcontrol("amount");         myboxes[15] = (textbox)dgi.findcontrol("quote status");         myboxes[16] = (textbox)dgi.findcontrol("excel file");         myboxes[17] = (textbox)dgi.findcontrol("folder location");         myboxes[18] = (textbox)dgi.findcontrol("architect");         myboxes[19] = (textbox)dgi.findcontrol("architectural firm");         myboxes[20] = (textbox)dgi.findcontrol("architect's phone");         myboxes[21] = (textbox)dgi.findcontrol("architect's fax");         myboxes[22] = (textbox)dgi.findcontrol("engineer");         myboxes[23] = (textbox)dgi.findcontrol("engineering firm");         myboxes[24] = (textbox)dgi.findcontrol("engineer's phone");         myboxes[25] = (textbox)dgi.findcontrol("engineer's fax");          (int j = 0; j < 26; j++)         {             myparams[j] = myboxes[j].text;         }     } 

i fairly, new asp.net research have done far has not provided me answer why update event not firing when click update button.

even if event handler firing, not update anything, because doing storing text value of each text box string array , not saving anywhere, nor updating ui (i.e. rebinding grid).

you need have logic similar in handler:

for (int j = 0; j < 26; j++) {     myparams[j] = myboxes[j].text; }  // send myparams string array logic save (i.e. database)  // rebind grid changes reflected user once exit edit mode dgdeditq.datasource = getdatafromdatabase(); dgdeditq.databind(); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -