Solved

C# updating database issue

Posted on 2016-08-25
3
60 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 (Megan) 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 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

16 Experts available now in Live!

Get 1:1 Help Now