c# & ASP.NET Gridview- Textbox data update in DB
I have a grid view with about six columns in which one of those columns is a text box.
User may enter a value in the texbox and when he clicks on Submit button(this button is not within the gridview) that single value has to be updated into the database. All other columns in the gridview will be retrieved from the DB. But this one column has to updated into DB. User may enter data for one row or all the rows (records) for this editabl开发者_高级运维e column.
Whenever there is some text change event for that textbox in gridview, I need to update the data for that particular record.
Please suggest as to how to get the value of that particualar column when many rows are edited.
Thanks in advance.
I would just add an onChange or onKeyDown method to each text box, and then write a method in JavaScript to update only that field.
<input type="text" id="myTextBox" onchange="$:someJavaScriptMethod()" />
If you wanted to handle it on the server side, you could subscribe to the TextChanged event of the TextBox, but not have the TextBox post back. When the submit button performed it's postback, the event handler for the TextChanged event would get called. In the event handler, you could persist the text to the DB.
精彩评论