Note that there are some explanatory texts on larger screens.

plurals
  1. POGet all checked hidden values from Gridview
    primarykey
    data
    text
    <p>I have a gridview with checkbox. When some one selects checkboxes i want get all checked hidden values and save into database.Below is my grid.</p> <pre><code>&lt;asp:GridView ID="grdBillableAssetDetails" AutoGenerateColumns="False" runat="server" Width="100%" DataKeyNames="ListId"&gt; &lt;HeaderStyle CssClass="GridHeader" /&gt; &lt;RowStyle BackColor="White" ForeColor="#284775" CssClass="GridRow" Height="25px" /&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Check AssetSubType" SortExpression="CheckAssetSubType"&gt; &lt;ItemStyle HorizontalAlign="Center" Width="100px" /&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="chkAssetSubType" runat="server" Checked='&lt;%#Eval("Select").ToString() == "1" ? true:false%&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:BoundField DataField="ListId" HeaderText="ListId" Visible="false"&gt; &lt;HeaderStyle HorizontalAlign="Center" Width="150px" /&gt; &lt;ItemStyle HorizontalAlign="center" Width="150px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="AssetType" HeaderText="AssetType"&gt; &lt;HeaderStyle HorizontalAlign="Center" Width="150px" /&gt; &lt;ItemStyle HorizontalAlign="center" Width="150px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="AssetSubType" HeaderText="AssetSubType"&gt; &lt;HeaderStyle HorizontalAlign="Center" Width="150px" /&gt; &lt;ItemStyle HorizontalAlign="center" Width="150px" /&gt; &lt;/asp:BoundField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>Below is my Code behind i want store list values and CompanyId into database.</p> <pre><code>protected void btnSave_ServerClick(object sender, EventArgs e) { try { int companyId = Convert.ToInt32(Request.QueryString["EntityId"]); List&lt;int&gt; listListId = new List&lt;int&gt;(); foreach (GridViewRow gvrow in grdBillableAssetDetails.Rows) { CheckBox chk = (CheckBox)gvrow.FindControl("chkAssetSubType"); if (chk.Checked) { int ListId = (int)grdBillableAssetDetails.DataKeys[gvrow.RowIndex].Value; listListId.Add(ListId); } } DataAccess.SaveListTypes(companyId, listListId); hdnPageStatus.Value = "0"; } catch (Exception ex) { hdnErrMsg.Value = ex.Message; } } </code></pre> <p>Can any please help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload