Solved

C# updating database issue

Posted on 2016-08-25
3
48 Views
Last Modified: 2016-08-26
See my error below in screenshots..

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

Accepted Solution

by:
zephyr_hex earned 500 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 21

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now