Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi All,

I am using asp.net 4.0
I have Data grid and i have put some template fields (textboxes).
I want to get the values of these text boxes on textbox_textchange event but i am unable.

Please any one can help me i will appreciate from my core of heart.

Raj
Posted
Updated 7-Jun-11 1:15am
v3
Comments
Morl99 10-Jun-11 16:24pm    
Please see my updated solution. If it does help you, please rate it accordingly.

1 solution

I have never done that, but could you just add an EventHandler for the Textbox?
<asp:TextBox runat="server" OnTextChanged="Text_OnTextChanged" ID="Text"></asp:TextBox>


In the CodeBehind you can just use the sender to get the Text:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
  TextBox text = sender as TextBox;
  text.Text; //this is the text.
}

While this might look like actual Code, this is untested pseudocode for illustration only!

Added after your clarification:
Ok so you need this:
Sub GridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs){
	Dim index As Integer = Convert.ToInt32(e.CommandArgument)
	Dim row As GridViewRow = GridView.Rows(index)
	TextBox lName = row.FindControl("Lname") as TextBox;
	TextBox fName = row.FindControl("FName") as TextBox;
	Label empId = row.FindControl("EmpId") as Label;
}


Assuming all your Controls have the id set like this in the ASP Markup id="Lname". This needs to be exactly like the Parameter of FindControl.

Hope this helps, and again no checked code, may contain typos.
 
Share this answer
 
v2
Comments
Sachin__Sharma 8-Jun-11 7:44am    
Thanks for reply
yes ur code works fine in case of get the value of same control but my problem is can i get the value of another textbox on this event. I mean



{
TextBox text = sender as TextBox;
text.Text; //here i can get only this controls value can i get another controls value from here.
}
Morl99 8-Jun-11 8:36am    
Sure, which control do you want? Do you want to synchronize all the text boxes? You could iterate through all the rows and use the Cell.FindControl method for that. Tell me what you need and I try to help you.
Sachin__Sharma 8-Jun-11 23:58pm    
i have a four columns datagrid like
EmpId FName Lname Save
(label) (textbox) (textbox) (Commandbutton)

These all are template fields


i want to get the values of all controls of a correspondence row when i click on command button.

I hope now u will understand my problem
Morl99 12-Jun-11 18:40pm    
Did my edit solve your problem? If so, please mark it as the solution and rate it accordingly.
Sachin__Sharma 13-Jun-11 0:39am    
No dear it dint solve my problem i have explain my problem above.

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