Click here to Skip to main content
15,906,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Grow=BindTextBoxGv.SelectedRow;
TextBox ValTextbox = (TextBox)row.Cells[1].FindControl("NameofFormTxt");
if (row.RowIndex == 1)
{
  ValTextbox.Attributes.Add("onblur", "return validateDate(this.id);");
}


This is my code.
Here I want to validate the Textbox in the grid so i taken the selectrow in the textbox text_change event but i am not albe to get the selectedrow why and how can i solve my problem. can any one help me.
Posted
Updated 14-Feb-11 21:00pm
v2
Comments
Albin Abel 15-Feb-11 3:36am    
On first sight...you are adding attributes to a new instance of the textbox
TextBox ValTextbox = (TextBox)row.Cells[1].FindControl("NameofFormTxt");

not the textboxes in the grid view

Second ValTextbox.Attributes.Add("onblur", "return validateDate(this.id);"); what is this.id here.

Try the below answer. if any problem let us know

1 solution

Hi Rajesh,

You need to do following:

.aspx.cs file

C#
void CustomersGridView_SelectedIndexChanged(Object sender, EventArgs e)
{
  // Get the currently selected row using the SelectedRow property.
  GridViewRow row = CustomersGridView.SelectedRow;
 
}


.aspx file
XML
<asp:gridview id="CustomersGridView"
       selectedindex="1"
       onselectedindexchanged="CustomersGridView_SelectedIndexChanged"
       runat="server" >
</asp:gridview>


Thanks,
Imdadhusen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900