for deleting the rows in gridview
aspx.cs code
protected void btndelete_Click1(object sender, EventArgs e)
{
//int index = this.grid.SelectedIndex;
//this.grid.SelectedIndex = -1;
//this.grid.DeleteRow(index);
string strid = string.Empty;
try
{
for (int i = 0; i < grid.Rows.Count; i++)
{
CheckBox chkdel = (CheckBox)grid.Rows[i].Cells[0].FindControl("chkdelete");
if (chkdel != null)
{
if (chkdel.Checked)
{
strid = grid.Rows[i].Cells[0].Text;
string Date = txtdate.Text;
grid.DataSource = assign.delassignment(Date);
grid.DataBind();
}
}
}
}
catch (Exception ex)
{
lblMsg.Text = ex.ToString();
}
//grid.DataBind();
}
protected void chkdelete_CheckedChanged(object sender, EventArgs e)
{
CheckBox chktest = (CheckBox)sender;
GridViewRow grdrow = (GridViewRow)chktest.NamingContainer;
TextBox txtAss = (TextBox)grdrow.FindControl("txtassign");
TextBox txtSub = (TextBox)grdrow.FindControl("txtsubject");
if (chktest.Checked)
{
txtAss.ReadOnly = false;
txtSub.ReadOnly = false;
}
else
{
txtAss.ReadOnly = true;
txtSub.ReadOnly = true;
}
}
private void uncheckall()
{
foreach (GridViewRow row in grid.Rows)
{
CheckBox chkuncheck = (CheckBox)row.FindControl("chkdelete");
TextBox txtAss = (TextBox)row.FindControl("txtassign");
TextBox txtSub = (TextBox)row.FindControl("txtsubject");
chkuncheck.Checked = false;
txtAss.ReadOnly = true;
txtSub.ReadOnly = true;
}
}
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder

New Topic/Question
Reply




MultiQuote



|