How to Add rows Dynamically to GridView
Hi team
Can anyone tell me how we can add rows dynamically in gridview.
DataTable dt = new DataTable();
try
{
CheckBox chk = new CheckBox();
foreach (GridViewRow row in gvDept.Rows)
{
chk = (CheckBox)row.FindControl("ChkDept");
if (chk.Checked == true)
{
Label lbl = (Label)row.FindControl("lblcode");
string code = lbl.Text;
dt = BLSht.GetEmployeeListAsPerDept(code);
if (dt.Rows.Count>0)
{
DataRow newRow = dt.NewRow();
gvAppEmployees.DataSource = dt;
}
else
{
}
}
else
{
}
}
gvAppEmployees.DataSource = dt;
gvAppEmployees.DataBind();
}
catch (Exception ex)
{
}
}