AutoGenerateColumns="false"
OnRowUpdating="GV_RowUpdating"
OnRowDeleting="GV_RowDeleting"
OnRowEditing="GV_RowEditing"
OnRowCancelingEdit="GV_RowCancelingEdit">
code behind...
protected void Page_Load(object sender, EventArgs e)
{
Bind();
}
public void Bind()
{
try
{
CTeam cTeam = new CTeam();
GridviewTeams.DataSource = cTeam.GetAllTeams();
GridviewTeams.DataBind();
}
catch (Exception err)
{
Response.Write(err.Message);
}
}
protected void BtnAdd_Click(object sender, EventArgs e)
{
CTeam cteam = new CTeam();
cteam.AddTeams(tbxTeamName.Text,tbxTeamEmail.Text);
Bind();
}
protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
CTeam cteam = new CTeam();
int indexrow = e.RowIndex;
short tid = short.Parse(((Label)GridviewTeams.Rows[indexrow].FindControl("GV_lblTeamID")).Text);
cteam.DeleteTeams(tid);
Bind();
}
protected void GV_RowEditing(object sender, GridViewEditEventArgs e)
{
GridviewTeams.EditIndex = e.NewEditIndex;
Bind();
}
protected void GV_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridviewTeams.EditIndex = -1;
Bind();
}
protected void GV_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
CTeam cteam = new CTeam();
int indexrow = e.RowIndex;
string tname = ((TextBox)GridviewTeams.Rows[e.RowIndex].FindControl("tbxEditTeamName")).Text;
string temail = ((TextBox)GridviewTeams.Rows[e.RowIndex].FindControl("tbxEditTeamEmail")).Text;
cteam.UpdateTeams(tname, temail);
GridviewTeams.EditIndex = -1;
Bind();
}
}
Iftikar HussainPosted Aug 24, 2013, 10:13 AM
Modify the below code and check
Regards,
Iftikar