Solved

Gridview UpdateProblem

Posted on 2013-01-14
4
297 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
ID: 38773606
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
ID: 38773617
here you will get some good examples

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

Author Comment

by:sarang8180
ID: 38773687
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
ID: 38775388
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn on intranet settings 1 57
ASP.net Javascript use multiple sliders 2 30
Master Content Pages, WebForms, and Session Variables 1 45
C#, asp.net MVC, sql server, LINQ 3 32
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

810 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