Reputation: 5020
I have an ASP.Net GridView, with two columns ("ID" and "name"). The name column is editable via an <asp:TextBox>. What I want to do is have the grid trigger its update event when the user clicks away from an editable cell.
I know I can attach an onBlur event handler to the TextBox to retrieve the value when the user clicks away. However, I don't know how to trigger the GridView's update event programmatically through JavaScript. Any suggestions?
Upvotes: 0
Views: 2872
Reputation: 11238
On your TextBox
set AutoPostBack="True"
. This will cause a postback when the client change
event fires, which is probably what you want rather than blur
. Attach a TextChanged
handler to the textbox and you can call your grid update method from there.
you can get the row index for the textbox that triggered the event like this:
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
GridViewRow gridRow = ((GridViewRow)((TextBox)sender).NamingContainer);
Console.WriteLine(gridRow.RowIndex);
}
Upvotes: 1
Reputation: 460108
You could set AutoPostback="True" on your Textbox and in the Codebehind save the new valuein the Event Handler.
Upvotes: 0
Reputation: 43074
You could call the submit method for your Form object from the onBlur event.
myForm.submit();
Upvotes: 0