Solved

C# updating database issue

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

ErrorError Code
0
Comment
Question by:SmashAndGrab
[X]
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
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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

690 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