Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck box value is not getting captured from grid view
    text
    copied!<p>I am trying to get read values from GridView and upload into database</p> <p>I am able to read the text value but unable to get the GridView CheckBox value ..</p> <p>I am getting only <code>false (0)</code> in database table while running the following code in asp.C#</p> <p>My Code at Button Event is as follows :-</p> <pre><code> protected void btnSave_Click(object sender, EventArgs e) { btnSave.Visible = false; btnEdit.Visible = true; int i = 0; string defaultvalue = "0"; foreach (GridViewRow row in grdExtApp.Rows) { string qry = "INSERT into tb_externalsystemaccess(User_Id, SystemName,Access_status) VALUES (@v1, @v2, @v3)"; SqlConnection con = new SqlConnection(str); using (SqlCommand cmd = new SqlCommand(qry, con)) { cmd.Parameters.AddWithValue("@v1", TextBox3.Text); cmd.Parameters.Add("@v2", SqlDbType.Text).Value = Convert.ToString (row.Cells[0].Text); CheckBox chkBx = (CheckBox)row.FindControl("AccessExternal"); if (chkBx.Checked) { defaultvalue = "1"; } cmd.Parameters.Add("@v3", SqlDbType.Bit).Value = Convert.ToInt16 (defaultvalue); con.Open(); cmd.ExecuteNonQuery(); i = i + 1; } } } </code></pre> <p>I am getting the v1 value from outside TextBox control.</p> <p>v2 value is from GridView cell ..it is a string value and I am able to capture it</p> <p>v3 value is CheckBox value ..it is not able capture ..instead shows only as false even though I check the CheckBox.</p> <p>My markup for GridView looks like this:</p> <pre><code> &lt;asp:GridView ID="grdExtApp" runat="server" AutoGenerateColumns="False" BackColor="White"&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="External_System" HeaderText="External System" /&gt; &lt;asp:TemplateField HeaderText="Access"&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="AccessExternal" runat="server" Enabled="true" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>Please help me why I am unable to get the checkbox value</p>
 

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