c# - How to update selected rows in ListView -
i have listview in asp.net web form . want select rows , update selected after button click.
want use checkbox/checkboxlist . don't understand how send information row or column in selected row checkbox/checkboxlist item .
how can select rows, , update them , using checkbox/checkboxlist ?
use asp.net linq entity framework.
code
<asp:button id="buttontest" runat ="server" onclick="buttontest_click" /> <asp:listview id="listview2" itemtype="doccat.models.reqinf" selectmethod="getreqf" onitemdatabound="listview2_itemdatabound" datakeynames="requestn" enableviewstate="true" runat="server" updatemethod="listview2_updateitem" deletemethod="listview2_deleteitem" insertmethod="listview2_insertitem"> <layouttemplate> <div class="outercontainer" style="overflow: scroll"> <table id="doctable"> <thead> <tr> <th> Выбрать </th> <th>first</th> <th>request</th> <th>third</th> <th>four</th> </tr> </thead> <tbody runat="server" id="itemplaceholder"></tbody> </table> </div> </layouttemplate> <itemtemplate> <tr> <td> <asp:checkboxlist runat="server" id="checknew" ><asp:listitem>Выбрать</asp:listitem></asp:checkboxlist></td> <td> </td> <td><%# item.birthdate.date%></td> <td><%# item.f1 %></td> <td><%# item.f2 %></td> <td><%# item.f3 %></td> </tr> </itemtemplate> </asp:listview>
selected rows don't display in checkboxlist items , in string selecteditems :
checkboxlist cblroles = listview2.items[0].findcontrol("checknew") checkboxlist; string selecteditems = ""; (int = 0; < cblroles.items.count; i++) { if (cblroles.items[i].selected) { selecteditems = selecteditems + cblroles.items[i].value + ","; } }
i used kind of ui. first created table ui, created populate table method in code behind.i used ado.net data access.
note: create stored procs getting data , updating data after button click.
step1: write populate table method in create object checkbox used radio button.
using (mtablerow = new htmltablerow()){ { #region radio button using (htmltablecell ltablecell = new htmltablecell()) { radiobutton mradiobutton = new radiobutton(); mradiobutton.id = "radio" + listinfo.id; mradiobutton.groupname = "rowselector1"; mradiobutton.autopostback = true; mradiobutton.checked = false; mradiobutton.checkedchanged += new eventhandler(availableradiobutton_checkedchanged); ltablecell.attributes["class"] = "radiobutton"; ltablecell.controls.add(mradiobutton); mtablerow.cells.add(ltablecell); #endregion // add remaining columns // add table row table.
step2: create method event click of checkbox.
Comments
Post a Comment