Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

how to add checkbox in gridview in asp.net through code?Iam creating Employee attendance entry i want check boxes in gridview. it will be change in every month(1 to 30). Please any body help me.

Previously i wrote this below code in c#.Please check this code and please tell to me how to write in ASP.Net?
Previously i wrote this code in C#.

C#
private void btnattendancelist_Click(object sender, EventArgs e)
        {
            label_msg.Visible = true;          
            dataGridView2.Visible = true;
            btnsetholiday.Visible = true;
            da = new SqlDataAdapter("select EmployeeId,(FirstNAme+LastName)as EmployeeName from EmployeeDetail", con);
            da.Fill(ds, "EmployeeDetail");
            dataGridView2.DataSource = ds.Tables["EmployeeDetail"];
            int count = ds.Tables["EmployeeDetail"].Columns.Count;

            for (int i = count, j = 1; i <= (31 + count - 1); i++, j++)
            {
                DataGridViewCheckBoxColumn cl = new DataGridViewCheckBoxColumn();
                cl.Name = "label" + i;
                cl.HeaderText = j.ToString();
                cl.Width = 25;
                dataGridView2.Columns.Add(cl);
            }
}
Posted
Updated 30-Oct-11 21:59pm
v6
Comments
Anuja Pawar Indore 31-Oct-11 4:00am    
Added pre tag

XML
<asp:GridView ID="gvRequestDetail" runat="server" >
<Columns>
<asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:CheckBox  ID="Check_select" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
 
Share this answer
 
v4
Comments
shek124 27-Oct-11 8:53am    
share your code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900