Solved

Gridview UpdateProblem

Posted on 2013-01-14
4
295 Views
Last Modified: 2013-01-14
How to Update the values in gridview if it shows old values....

 FillData();
           
            GridViewRow gr1 = (GridViewRow)dgrData.Rows[e.RowIndex];
             
            TextBox tCategory=(TextBox)gr1.FindControl("txtCategory");
         
            //DataBind();
            string update = "update category set category='" + tCategory.Text + "' where cat_id=" + dgrData.DataKeys[e.RowIndex].Values[0].ToString() + "";
0
Comment
Question by:sarang8180
4 Comments
 
LVL 8

Expert Comment

by:deepu chandran
Comment Utility
Hi,

Call the Load Grid function again,that means

1) Get the data from the DB
2) the List/Dataset/Datatable assign to Grid.Datasource
3) call Grid.Databind() again

-- Deepu
0
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
here you will get some good examples

http://forums.asp.net/t/1255252.aspx/1
0
 

Author Comment

by:sarang8180
Comment Utility
if i call the data from database again and bind to gridview,it shows old data in textbox of gridview.

If i don't call,keep it in !IsPostBack.Then Gridview vanishes on click of update link
0
 
LVL 20

Accepted Solution

by:
informaniac earned 500 total points
Comment Utility
You should call the code to retrieve the data after the call to update is complete. This way, the textbox value will be stored in the Database.

If I've got it completely wrong, please post some more of the code... i.e. how are you binding the code. update code.. etc..
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Async and await with MVC and Web Api 3 29
What is MicroStrategy.NET? 2 43
Using MS Code on my Mac 6 44
Paging GridView 7 32
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

12 Experts available now in Live!

Get 1:1 Help Now