.net - getting label text in gridview -


i want cell value gridview,but empty string returned .i implemented
code in selectedindexchanged event of radiobuttonlist .i iterate through gridview , access cell code .but problem stll remaining.i used 3 itemtemplate ,each has 1 elemnt each element own coulmn .aspx

      <asp:gridview id="gridview2" runat="server" autogeneratecolumns="false" >                   <columns> <asp:templatefield>     <itemtemplate>                 <asp:label id="label2" runat="server" text='<%# eval("qno") %>'>             </asp:label>                </itemtemplate>           </asp:templatefield>            <asp:templatefield>            <itemtemplate>                     <asp:label id="label3" runat="server" text='<%# eval("description")          %>'>            </itemtemplate>           </asp:templatefield>     <asp:templatefield>     <itemtemplate>           <asp:radiobuttonlist id="radiobuttonlist1" repeatdirection="horizontal"             runat="server" onselectedindexchanged="changed"  autopostback="true" >                <asp:listitem   value="agree" selected="true" >               </asp:listitem>                <asp:listitem                  value="disagree">               </asp:listitem>                <asp:listitem value="strongagree">               </asp:listitem>                <asp:listitem value="strondisagree">               </asp:listitem>                 </asp:radiobuttonlist>     </itemtemplate>     </templatefield>                 </columns>             </asp:gridview>           <asp:label id="labe11" runat="server" ></asp:label>         code behind: public void changed(object sender, eventargs e) {                for(int i=0;i<gridview2.rows.count;i++)               {                   string labtext;                     radiobuttonlist list =              gridview2.rows[i].cells[2].findcontrol("radiobuttonlist1") radiobuttonlist;                    labtext= gridview2.rows[i].cells[0].text;                      label1.text = labtext;                 }                        } 

have included html .aspx page above? have there not going work. itemtemplates not form columns, included within templatefield columns.

example (adapted code,
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.itemtemplate.aspx
, http://msdn.microsoft.com/en-us/library/aa479353.aspx):

<asp:gridview id="gridview1" runat="server"      <columns>          <asp:templatefield headertext="description">             <itemtemplate>                 <asp:label id="label3" runat="server" text='<%# eval("description") %>'>             </itemtemplate>         </asp:templatefield>          <asp:templatefield headertext="choice">             <itemtemplate>                 <asp:radiobuttonlist id="radiobuttonlist1" repeatdirection="horizontal" runat="server" onselectedindexchanged="changed"  autopostback="true" >                     <asp:listitem value="agree" selected="true" />                     <asp:listitem value="disagree" />                     <asp:listitem value="strongagree" />                     <asp:listitem value="strondisagree" />                 </asp:radiobuttonlist>             </itemtemplate>         </asp:templatefield>      </columns> </asp:gridview> 

you'll need separate templatefield definition each column.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -