Hello Friends,
Now I am going to explain to find a GridViewRow in TextBox TextChanged Event inside GridView
Some times we had a TextBox or CheckBox or any other control inside GridView and we have to find the GridViewRow when the TextChanged or CheckedChanged or concerned Event fires
The following code show us how to do that
in same way you can find gridview in any event inside gridview
}
Now I am going to explain to find a GridViewRow in TextBox TextChanged Event inside GridView
Some times we had a TextBox or CheckBox or any other control inside GridView and we have to find the GridViewRow when the TextChanged or CheckedChanged or concerned Event fires
The following code show us how to do that
protected void txtTest_TextChanged(object sender, EventArgs e)
{
{
// code to find text box
TextBox txtTextBox = ((TextBox)(sender));
TextBox txtTextBox = ((TextBox)(sender));
// code to find GridViewRow using naming container (bubble Event)
GridViewRow grdRow = ((GridViewRow)(txtTextBox.NamingContainer));
GridViewRow grdRow = ((GridViewRow)(txtTextBox.NamingContainer));
// code to find Label inside GridViewRow
Label lblTest = grdRow .FindControl("lblTest") as Label;
Label lblTest = grdRow .FindControl("lblTest") as Label;
}
in same way you can find gridview in any event inside gridview
protected void chkApproved_CheckedChanged(object sender, EventArgs e)
{
try
{
CheckBox chk = ((CheckBox)(sender));
GridViewRow gv1 = ((GridViewRow)(chk.NamingContainer));
}
{
try
{
CheckBox chk = ((CheckBox)(sender));
GridViewRow gv1 = ((GridViewRow)(chk.NamingContainer));
}
catch (Exception ex)
{
// handle your exception
}{
// handle your exception
}
No comments:
Post a Comment