Note that there are some explanatory texts on larger screens.

plurals
  1. POcheck checkbox inside gridview either it is checked or not?
    primarykey
    data
    text
    <p>I have gridview which contains the checkbox as templatefield. I have tried so hard but I am still unable to get the desired results, that is if check box is checked, than perform action-1 otherwise perform action-2, but everytime it is performing action-2. Below is my code I need little help from your side.</p> <p>Gridview code:</p> <pre><code>&lt;asp:GridView ID="final" runat="server" AutoGenerateColumns="False";&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="name" HeaderText="Employee Name" SortExpression="date" /&gt; &lt;asp:BoundField DataField="ldate" HeaderText="Date Of Leave" SortExpression="ldate" /&gt; &lt;asp:TemplateField HeaderText="Half/Full"&gt; &lt;ItemTemplate&gt; &lt;asp:RadioButtonList ID="RadioButtonList1" runat="server"&gt; &lt;asp:ListItem Enabled="true" Value="Half"&gt;Half&lt;/asp:ListItem&gt; &lt;asp:ListItem Enabled="true" Value="Full"&gt;Full&lt;/asp:ListItem&gt; &lt;/asp:RadioButtonList&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="Approve"&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>code I have made to check the radio and checkbox:</p> <pre><code>DataTable dtable = new DataTable(); dtable.Columns.Add(new DataColumn("Date", typeof(DateTime))); dtable.Columns.Add(new DataColumn("Half/Full", typeof(float))); dtable.Columns.Add(new DataColumn("Status", typeof(string))); Session["dt"] = dtable; SqlConnection conn = new SqlConnection(); conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["leave"].ConnectionString; conn.Open(); foreach (GridViewRow gvrow in final.Rows) { dtable=(DataTable)Session["dt"]; CheckBox chk = (CheckBox)gvrow.FindControl("CheckBox1"); if (chk != null &amp; chk.Checked) { RadioButtonList rButton = (RadioButtonList)gvrow.FindControl("RadioButtonList1"); if (rButton.SelectedValue == "Half") { //perform action-1 } else { //perform action-1 } } else { perform action-2 } } </code></pre> <p>everytime it's going into the last else...why?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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