?
Solved

C# updating database issue

Posted on 2016-08-25
3
Medium Priority
?
126 Views
Last Modified: 2016-08-26
See my error below in screenshots..

ErrorError Code
0
Comment
Question by:SmashAndGrab
3 Comments
 
LVL 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 total points
ID: 41770740
This is likely due to the order of when you're binding the gridview vs when you're looking for the new value.

Do you have viewstate enabled?  And if so, do you only bind your data to the gridview when it's not postback?  This could be a problem if you always bind, and not just when it's not postback.

Have you checked the value of the field in Request.Form ?

You can do that as follows:
for (int i = 0; i < gvGridView.Rows.Count; i++)
{
  GridViewRow r = gvGridView.Rows[i];
  TextBox tb = (TextBox)r.FindControl("tbStuff");
  var postedVal = Request.Form[tb.UniqueID];
}

Open in new window

0
 
LVL 22

Expert Comment

by:Tapan Pattanaik
ID: 41770784
Hi SmashAndGrab,

Use OnTextChanged event of the textbox in GridView which will solve your problem.

Check sample example:

http://www.codeproject.com/Tips/663684/Fire-TextBox-TextChanged-Event-from-GridView
 
Regards,
Tapan Pattanaik.
0
 

Author Comment

by:SmashAndGrab
ID: 41771389
@zephyr_hex  - thank you.  You were correct.

I was re-binding the GridView before running the update routine!  Must have missed that!

Thank you!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question