C# - GridView Isn't Updating Properly

Sep 14, 2010

I have a Gridview with these parameters:

<asp:GridView runat="server" ID="ItemGrid" CssClass="Grid"
AutoGenerateDeleteButton="true" OnRowDeleting="RowDeleting"
AutoGenerateEditButton="true" onRowEditing="RowEdit"
OnRowCancelingEdit="CancelRowEdit" onRowUpdating="RowUpdating"
<asp:BoundField HeaderText="Item" DataField="Item"/>
<asp:BoundField HeaderText="Family" DataField="Family"/>
<asp:BoundField HeaderText="Structure" DataField="Structure"/>
<asp:BoundField HeaderText="Updated" ReadOnly="true" DataFormatString="{0:d}" DataField="Updated"/>

On updating it calls:

protected void RowUpdating(object sender, GridViewUpdateEventArgs e){
int Item_ID = (int)this.ItemGrid.DataKeys[e.RowIndex][0];[code]...

It generates the Update/Edit/Delete buttons, my Delete function is working exactly how I want and the 'Edit' button generates editable TextBoxes as it should.

My problem is in the updating part, the strings Item, Family, Structure are getting the old values, not the new values I put in the generated text boxes.If I hard code in values they are updated to the database and the DateTime.Now is always updating correctly in the database so the update query is working.

I've been looking at this/reading forums testing things for a couple days now. I'm sure I'm just missing something simple that I have overlooked.

Edit:It has been answered but for those who were curious this is my dataBind();

protected void dataBind()
ItemTableAdapter taItem = new ItemTableAdapter();
this.ItemGrid.DataSource = taItem.GetActive();

View 3 Replies

Similar Messages:

AJAX :: Vetical Scroll Not Woking Properly While Updating Gridview?

Aug 19, 2010

In one my web page i've an updatepanel which contains a gridview .The gridview displays huge amt of data (4 pages of data) and the updatepanel refreshes for every 1 sec,for tht i've used timer control, to get the updated data from the server.for that i've used one timer. The problem is ,the webpages scroll bar(both horizontal and vertical) is repositioning to the starting position after every refresh.


View 2 Replies

Forms Data Controls :: How To Set Up The Viewstates So It Binds Properly When The Editing And Updating

Apr 27, 2010

I have a Gridview set up so when a user clicks the various buttons it sorts the results. I have a couple problems. Right now the way i have the viewStates set up, it is only working when the buttons are clicked twice. I Was also wondering how to set up the viewstates so it binds properly when the editing and updating. I have read up on ViewStates and I am still a bit confused.


View 5 Replies

C# - How To Properly Filter Gridview Bound To Sqldatasource

Sep 21, 2010

I am trying to populate an (editable) gridview in ASP.NET with a table from SQL. I have a SQLDataSource set up for this. I also need to have this gridview be filterable based on parameters entered in textboxes. I have tried using ControlParameters for this and it works but the problem there is when all textboxes are empty I want it to display all results in the gridview. What it does is display nothing because no entries have parameters that equal "". Is there an easy way to do this that I am missing or is there a better way to go about it other than a SQLDataSource?

View 1 Replies

Gridview Datasource Set Properly But Not Displaying Records?

Jun 15, 2010

using vb.net/asp.net 2005 and SQL Server 2005 In my vb.net code I am setting the select statement for SqlDataSource1 and after that I am setting the DatasourceID for my gridview called grdGV (see below). However no rows are being displayed in the grid and the Rows.Count that I am printing out is 0. But when I taked the SqlDataSource1.SelectCommand printed out in my response.write statement below and query this in my SQL database I see 2 records being returned. So I am very puzzled why the database will return 2 records but the same exact query that is set in the SqlDataSource and then bound to the grid does not return 2 records?

I have also checked the DataSource.ConnectionString and it matches the database I am using.


View 4 Replies

Web Forms :: Excel Data To Gridview Not Working Properly

Apr 14, 2010

I have a gridview for which i have provided two options one to export grid data and another to import excel data to gridview. I have no problems with the former. In the latter part i want to achieve something like this. When user user exports gridview data to excel and lets say makes some changes i.e there were 10 items he deletes 4 of them. and saves the excel file.Now when he tries to import this excel file i want the checkbox(already present) to be checked for the 6 items of the 10 items in the gridview. how can i accomplish this. To import excel data to gridview i am using this method: In the importtogrid button,


this is the Import_to_grid method: [Code]....

View 1 Replies

Forms Data Controls :: How To Update Parent Gridview After Updating Child Gridview

Dec 14, 2010

I have a parent gridview which has a child gridview in the itemsTemplate. Both are binded to different SqlDataSources. I can successfully update and delete rows in the child gridview. After updating in the child gridview, some related data in the parent gridview are not updated automatically. So i have placed ParentGridview.Databind() in the rowupdated event of child gridview. But it doesnt look working.

How can i accomplish this?

View 4 Replies

Forms Data Controls :: Updating GridView Based On Computation In Another GridView

Jan 27, 2010



View 1 Replies

Forms Data Controls :: Updating GridView With GridView Columns That Are Readonly

Feb 20, 2011

I have a GridView with 5 fields. Only two of the fields are edittable (the others are READONLY).

I have an UpdateCommand as follows

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NHLPOOL %>"
SelectCommand="SELECT [PlayerID], [Firstname], [lastname], [Goals], [Assists], [Goals]+[Assists] as Points, [AsOfDate] FROM [PlayerStats], [Player] where [PlayerStats].[PlayerID] =[Player].[ID] ORDER BY Points DESC"
UpdateCommand="UPDATE PlayerStats SET Goals =@GOALS, Assists =@ASSISTS, AsofDate=GETDATE() WHERE PLAYERID = @PLAYERID">

The issue is I want the PLAYERID GV column to be READONLY but I get a runtime error when updating if the PLAYERID is READONLY.

I get the error "

Must declare the scalar variable "@PLAYERID"."

View 1 Replies

Forms Data Controls :: Gridview Row Edit Only Works Properly For Odd

Feb 9, 2011

I have this weird problem that sometimes happen to me. I have gridview with some columns, one of them is for a textbox. So I want when user click to edit the row, that textbox will get focused. What I used is simply: type(gridV.Rows(e.newEditIndex).FindControl("TB"),TextBox).Focus(). However, only when I click on odd rows that it works. When I click on even rows, the row change to edit mode but somehow its RowState still state Normal.

View 3 Replies

Forms Data Controls :: Sorting In Gridview Not Working Properly

Feb 3, 2010

have a gridview which i a using for sorting data in it.IT sorts the first time i click on cloumn in ascending order.When i click on column again , i want to sort it in descending order again , but it does not happen ,

protected void SearchResultsGridView_OnSorting(object sender, GridViewSortEventArgs e)
SortDirection sortDirection = GetSortDirection(e.SortExpression);
presenter.SortResultsView(sortDirection.ToString(), e.SortExpression);

View 4 Replies

Forms Data Controls :: Gridview To Formview Not Selecting Properly?

Mar 26, 2010

I use a gridview to select data to display in a formview.

Everything works fine on the first page, but when I page the Gridview to the next page, it still selects the item from the first page

my code is


View 4 Replies

VS 2010 - GridView Updating Event When GridView Has Paging

Dec 1, 2013

I have a GridView that is populated via a dataset that contain 1 table. I have enabled paging on my GridView.

In my Updating event, I handle the new values and call a store proc to update my database with the new values for the selected row. In order to minimize the call to the DB, instead of getting back a new dataset with the updated values, I simply update the row of the dataset that I have in session with the new values and then I bind back my gridview.

The problem that I have is since I have let's say 5 pages of 10 row... If I update a row on the first page as soon as I click update, the gridview will show the new values. However, if I select page 3 for example, click on update and update the values, once the update is done, the gridview will still be displayed with the old values.

View 4 Replies

Forms Data Controls :: GridView OnClinetClick Event Is Not Working Properly?

Dec 14, 2010

I am trying to put onclientclick on linkbutton in aspx code page but it is not working single quote is showing as ' I try to put the code in RowBound Event of Gridview but still same. I am using .net 4.0

View 26 Replies

Forms Data Controls :: GridView Editing Not Working Properly After Sorting On Any Column

Jun 2, 2010

whn i click edit button on grid before sorting on any column it is working properly...but once i click on any column for sorting n thn click on edit then the rows get sorted again and edit is set on some other row... plz help me...herez my code..

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
gv_photo.EditIndex = e.NewEditIndex;
public void bindgrid(string sort)
string str = "select * from tbl_Album";

View 2 Replies

ADO.NET :: Row Updating In A Gridview?

Feb 23, 2011

I am updating values in a gridview below is my code [Code]....

but whenever i update the value it is not getting updated in the database and it is not showing any error.

View 3 Replies

Which GridView Event To Use When Updating

Jun 28, 2010

I have a GridView with ItemTemplate and EditTemplate. There is some text boxes in EditTemplate. I want to update records myself using EditTemplate controls. Which event of GridView I should use? If I use Telerik's RadGrid then what event is better?

View 1 Replies

VS 2008 GridView - How To Refer To The Row That Is Updating

Mar 13, 2010

I'm facing the following issue:

I have a gridview that allows updating. I only want to show the relevant fields to the user. As a result I hide the ID field of the records. But I need this value as a parameter for my update command. Apparently the value is always passed as 0 when the field is set invisible. When the field is set visible, the right value is passed.

I know it is possible to refer to a selected row and its controls, to get their values, even for invisible fields. This is what I want to do when the row is updating, in order to get the ID value of the label control which holds the ID value. How do I refer to the row that is updating? I experienced that the row is not considered 'selected', so the SelectedRow property of the gridview does not do the trick.

View 4 Replies

Dropdownlist On Gridview Updating Only First Value To The Database

Dec 8, 2010

I have a grid view and have five dropdownlist on it. I have edit update and cancel edit buttons on each row.

Drop down list is updating the database, but only first value in the dropdownlist even when user select second, third or any other value from the dropdownlist.

What could possible be the reason for this. Here is my row Edit/ CancelEdit and Updating Events.


View 2 Replies

C# - TemplateField Not Updating In GridView Using LINQDataSource?

Sep 2, 2010

Im using a LINQDataSource to populate a GridView of Universities.

Each University has an associated State, which is in another table and associated by a foreign key (StateID).

I have a TemplateField in the GridView so that when you view it normally it displays the StateName which comes from the State table and when you edit it shows a DDL populated with everything from the State table.


If I debug, inside of RowUpdating, GridViewUpdateEventArgs.NewValues doesnt even have a key for State.

Question: How do I let my gridview know I want it to update this column? All the BoundFields just seem to work...

View 1 Replies

Asp - Updating GridView With DataSet Source

Mar 23, 2011

I am working on a page to let a user import an excel file into our database. I want to allow the user to manipulate certain fields before committing the information so I loaded a DataSet from the Excel file and bound that to a GridView. For some reason on rowUpdate my NewValues collection is empty. Here is my GridView:

<cc1:WWGridView ID="gvImportDisplay" runat="server" CssClass="grid-view" AllowSorting="false" ShowHeader="true"
<EmptyDataTemplate>0 results found. </EmptyDataTemplate>

View 2 Replies

C# - Updating GridView Data Using LINQ?

Mar 24, 2011

I have a GridView which needs to get updated on RowUpdating Event. How can I update data using LINQ?

I am populating GV using LINQ too and here is the code for that:

protected void Page_Load(object sender, EventArgs e)
string getEntity = Request.QueryString["EntityID"];
int getIntEntity = Int16.Parse(getEntity);
using (OISLinq2SqlVs1DataContext dt = new OISLinq2SqlVs1DataContext())


View 1 Replies

VS 2008 - Gridview With ObjectDataSource Row Updating

Jul 5, 2011

Which is the correct event to handle Updating of a row in my gridview. The gridview is bound to an objectdatasource. I added a tamplate field like this to handle editing a row:

<asp:TemplateField ShowHeader="false">
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"> </asp:LinkButton>

[Code] ....

No I need to handle the Update Button click.I need to set the ObjectDatasources Update params and call the update method. I'm not sure which is the correct event to do this. IS it gridview_RowUpdating??

View 1 Replies

Web Forms :: Updating Just One Field In The Gridview Update?

Aug 9, 2010

I was wondering if when you add the update link for gridview records, is there a way to only allow the user to update just one field in the record?

View 1 Replies

AJAX :: Gridview's In Update Panel Not Updating

Aug 27, 2010

I have 2 gridviews in an update panel that for some reason will not update. There is no data entry, paging, sorting going on, the data is just there to be displayed. I'm using a timer that initiates every 5 minutes to trigger the updatepanel. I also have an updatepanel on an additional page where I am also using a trigger to fire the updatepanel with 2 charts and 1 oneline/column gridview. The 2 charts update just like they are supposed to however the gridview does not. Here is the code for the 2 Gridview aspx page:


Does anyone know the solution to this issue or if Gridviews just don't refresh in UpdatePanels.

View 7 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved