RowCommand Event:
1. GridViewRow grv = ((GridViewRow)((DataControlFieldCell)((LinkButton)e.CommandSource).Parent).Parent);
Using NaingContainer
2. GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
int rowIndex = row .RowIndex;
RowDeleting, RowUpdating Event:
int UserID = Convert.ToInt32(GridUser.DataKeys[e.RowIndex].Values["txtUserID"]); //DataKey
TextBox txtUserName = (TextBox)GridUser.Rows[e.RowIndex].FindControl("txtUserName");
SelectedIndexChanging Event:
Label name = (Label)GridUser.Rows[e.NewSelectedIndex].FindControl("lblUserName");
OnRowDataBound:
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblName = (Label)e.Row.FindControl("lblName");
}
DropDown Selected Index Changed, TextBox Changed Event:
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.Parent.Parent;
int idx = row.RowIndex;
DropDownList ddlCountry= (DropDownList)row.FindControl("ddlCountry");
Button Click Event:
TextBox txtuser = (TextBox)GridUser.FooterRow.FindControl("txtNewUserName");
1. GridViewRow grv = ((GridViewRow)((DataControlFieldCell)((LinkButton)e.CommandSource).Parent).Parent);
Using NaingContainer
2. GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
int rowIndex = row .RowIndex;
RowDeleting, RowUpdating Event:
int UserID = Convert.ToInt32(GridUser.DataKeys[e.RowIndex].Values["txtUserID"]); //DataKey
TextBox txtUserName = (TextBox)GridUser.Rows[e.RowIndex].FindControl("txtUserName");
SelectedIndexChanging Event:
Label name = (Label)GridUser.Rows[e.NewSelectedIndex].FindControl("lblUserName");
OnRowDataBound:
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblName = (Label)e.Row.FindControl("lblName");
}
DropDown Selected Index Changed, TextBox Changed Event:
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.Parent.Parent;
int idx = row.RowIndex;
DropDownList ddlCountry= (DropDownList)row.FindControl("ddlCountry");
Button Click Event:
TextBox txtuser = (TextBox)GridUser.FooterRow.FindControl("txtNewUserName");
No comments:
Post a Comment