Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

C# updating database issue

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

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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