Vikas Singh

Vikas Singh

  • 1.3k
  • 410
  • 14.5k

How can I check that checkbox is checked or not inside grid view

Sep 13 2020 6:47 AM
How can I check that checkbox is checked or not inside grid view without using loop--
 
Actually i want to work like onrowcommand 
 
this is checkbox inside gridview-------
<asp:CheckBox runat="server" ID="chkselect" OnCheckedChanged="chkselect_CheckedChanged"
CommandName="chkboxselect" AutoPostBack="true" CommandArgument='<%# Eval("hnysku") %>' />
 
this is C# code which is working like onrowcommand but here is another problem how can i check checkbox is checked or not --- 
 
List<string> list = new List<string>();
var chk = (CheckBox)sender;
var CommandName = chk.Attributes["CommandName"];
if (CommandName == "chkboxselect")
{
var CommandArgument = chk.Attributes["CommandArgument"];
if (Convert.ToBoolean(chk.Attributes["Checked"]) == true)
{
list.Add(CommandArgument);
}
else
{
list.Remove(CommandArgument);
}
}

Answers (1)