.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

question about gridview updating

Posted By:      Posted Date: October 02, 2010    Points: 0   Category :ASP.Net

Hello, i have some GridView Using LinqDataSource1 (GridView1). i want the gridview to update everytime the user make something on page so im using GridView.DataBind() in the Page_Load method on code behaind (isPostBack statement) and its working fine!!! (the user make something on view1 on Multiview and then jump to view2 to see the gridview) the problem is, when the user want to edit some row in the gridview (using the gridview commands) the data dont update!! he can only delete rows. when im removing the isPostBack statement its working and the user can update and delete but i need the isPostBack so the gridview will update his rows. any idea?????

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="userFileId" DataSourceID="LinqDataSource1" 
            ForeColor="#333333" GridLines="None" Width="540px" Font-Names="Arial" Font-Size="X-Small">
            <RowStyle BackColor="#EFF3FB" />
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="fileName" HeaderText="?? ?????" 

View Complete Post

More Related Resource Links

GridView Question - Please Help Me...Should Be Simple...

Hello,I have what I think should be a simple GridView question but I can't find the answer.When I want to update a row in Gridview I click on the "Edit" link.  It takes me into the row of the GridView where I can edit the values.Here's how it looks:   CustomerID CompanyName Edit 001 IBM Microsoft Apple Google Edit 002 IBM Microsoft Apple Google Edit 003 IBM Microsoft Apple Google Edit 004 IBM Microsoft Apple Google When I click on "Edit" it looks like:   CustomerID CompanyName Edit 001 IBM Microsoft Apple Google Update Cancel IBM Microsoft Apple Google Edit 003 IBM Microsoft Apple Google Edit 004 IBM Microsoft Apple Google As you can see, I now have the ability to update the CustomerID.  I don't the user to be able to update the CustomerID, only the CompanyName via the DropDown.How can I change the GridView to ONLY allow me to update the CompanyName?ThanksJason   CustomerID CompanyName Edit 001 IBM Microsoft Apple Google Edit 002 IBM Microsoft Apple Google Edit 003 IBM Microsoft Apple Google Edit 004 IBM Microsoft Apple Google

Gridview's in Update Panel not updating

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:</head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Timer ID="Timer1" runat="server" Interval="300000" Enabled="True"> </asp:Timer> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> <ContentTemplate> <table class="style1"> <tr>

Question in row group not updating on when the column value changes

I'm using Report Builder 3.0 and created a row group column and then moved it to a row about the detail columns instead of leaving it as a column at the left.  When I run the report the group value doesn't change  but the page break occurs.  I added the same field as a column so I can see the value is different. Why is the row group field not changing?

Updating gridview attributes from javascript

Hello,   I have been trying to use a custom attribute in my gridview to pass a comma delimited list of guids between my server-side and client side code.  Normally I would just use a hidden-field to do this, but I have to add a hidden-field into a row in my gridview to use one.  Since I need access to the updated value from javascript before my grid is rendered on postback, I can't use a control that is buried inside a row.  So instead, i was trying to add an attribute to the gridview and having the javascript update that value.   Here is the private property defined in my extended gridview class:  private List<Guid> _selectedValues { get { List<Guid> myList = new List<Guid>(); if (this.SelectionType != SOMgridviewSelectionType.None) { if (ViewState["SelectedValues"] != null) { return (List<Guid>)ViewState["SelectedValues"]; } } return myList; } set { if (this.SelectionType != SOMgridviewSelectionType.None) { if (string.IsNullOrEmpty(this.Attributes["hiddenSelectedValues&q

Adding user names when updating gridView

Hi All,May be this is a begineers question, could someone help on this please?I'm using a windwos authentication via intranet. I'm able to display the username in a label control on a page load event (which is very simple). I'm not storing this data anywhere in the table (MS SQL). I have all my data in a table and I'm using a gridview to diplay them. I'm using a button control to update all the rows in the gridview. I wanted to update three columns in the gridview (1. Tickbox, 2.Datetime Stamp and 3.UserId).I've created a query in the dataset, through which i can update the Tickbox and DateTime stamp using now() function. But I'm not sure how to update the UserID field with the UserName (which inturn updates all the three fields in the gridview when the button is pressed.

GridView updating problem


Hi all,

I'm trying to edit fields in my gridview, but for some reason it's not working. I've tested the sproc, and there's no apparent reason why it shouldn't work. When debugging the app and looking at e.Command.Parameters in both Updating and Updated (SqlDataSource), it only shows me the old values, which, to me, implies that this is the problem - it's not sending the updated values.

Anyone know how to fix this?

Cheers! :)

<asp:GridView ID="gvDisplayGroup" runat="server" AutoGenerateColumns="False" 
        <asp:BoundField DataField="RoleId" HeaderText="RoleId" 
            SortExpression="RoleId" ReadOnly="true" />
        <asp:BoundField DataField="RoleName" HeaderText="RoleName" 
            SortExpression="RoleName" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="role_level" HeaderText="role_level" 

GridView edit not updating



Can someone tell me where I have gone wrong? changing from VS2003 DataGrid to VS2010 GridView; still on SQL Server 2000 so the wizards for autogenerating the code are not compatible.

Delete works, RowUpdating does not. I get an ArgumentOutOfRangeException on "rowToUpdate("QuoteDQty") = Me.dgQuoteList.Rows(e.NewValues.Item(1).ToString)"

Gridview question


I have a page which as been working just fine for months, that is simply pulling SQL data to a dataset, and on the RowDataBound event, I am adding a new cell to the row, a hyperlink to another page which is based on text data in certain columns of the row. All of that is fine. This week I have been trying to figure out a way to add one more column based on a user request. They would like to have a checkbox column and a button that performs an act with each of the checked items. This value doesn't need to be stored anywhere, and is only used in the session to determine what rows this action is taken against.

I am a noob to asp.net, usually spending time in Winform apps, but trying to help someone out by providing web page access to some data. I have scoured the pages trying to sort out whether I need to rewrite the page and data access in some way but there seems to be many many different ways people have solved similar problems. I think I have gotten really close a few times but either end up with a checkbox which I cannot get the value for (by adding cells in the same code that adds the hyperlink), to adding a templatefield. In this attempt what happens is that if I keep autogeneratecolumns=true then my databinding blasts over the templatefields and if I set it to false, nothing happens on databinding.. 

I really apologize to the many advanced users who

Question regarding C# Paging Gridview


Dear Experts,

i have an application in Vs. C# i have gridview with big data so its not in graphical mode so i want to paging in gridview . is there any command in C# to enter paging in gridview ?



Noob question about updating label.


I'm having a label in a page which I need to be updatet multiple times when a method in the codebehind file fires, like this:

protected void updateLbl()


lbl1.Text = "test1";


lbl1.Text += "test2";


but the label first updates when the method finishes. How can I solve this? Do I need AJAX?

Thanx in advance.

GridView question


I have a GridView. The data is displayed in TemplateFields: textboxes and dropdown lists. E.g. rows 5 and 7 have certain values selected in the dropdown lists of column 1. After I use filtering, still the same values are selected in rows 5 and 7, though because of filtering, different records are displayed in those rows. The same thing happens with TextBoxes.

Could you tell me how I could avoid preserving data after postback?

I tried to disable ViewState of the GridView or of the dropdown lists or textboxes, but that didn't help.


Gridview DataKeyNames question



I am trying to get the delete to work on my gridview. I've added a


but when i click delete i get

Input string was not in a correct format.

Gridview column line wrap question


I have a ASP.NET gridview (embedded into a DIV) with several columns. For some columns line wraps are definied and for some not(with ItemStyle.Wrap = true/false). For all columns ItemStyle.Width is set to a specific value. Now I am wondering, that there is a line wrap in a column, where ItemStyle.Wrap = false. What could be the reason for that?

DataTable and it's Gridview - A Column Order Question


Well, I've been developing with gridviews for quite some time now.  Just recently I came across a situation that has me stumped.  Here's how the gridview has been working for me.


1.      A stored procedure from the database is called (three parameters are passed (reporttype, name, location)

2.     The data is retrieved using the SqlDataAdapter to fill a Datatable


4.     Columns are created programmatically as it reads the DataTable results (headertext, datafield, and dataformatstring are set at runtime)

5.     The Gridview triggers the databind event - and voila it works.


My dilemma is this:  the stored procedure (that I haven't developed) returns a various set of columns and column order.  I have one report type that does the following:


ReportType 1:  column orders returned in the following order when running directly in SQL

            col B, col C, col D, col E, col A


when I run the report through my gridview, the column order is as follows:


Gridview not updating


I will appreciate any help if someone could solve this problem.

i have a form with a gridview that does the edits. I have a detailsview that does the inserts. If I test the run the form using default values as parameters the form wors fine. If I use a the hyperlinked field as below to go to the form the form does not work.


         <asp:HyperLinkField DataNavigateUrlFields="PONumber"
                  DataTextField="PONumber" HeaderText="PONumber" 
                  NavigateUrl="ASPPO_items.aspx" Target="_blank" />        



Problem with gridview manual updating


 I have a gridview that is connected to a SQL db. I am handling the update manually in the GridView1_RowUpdating event where I pull data out of the edited row the make calls to classes that update the DB. I am not using the built in updatecommand of the grdiview because I am doing some complex and multiple table updates.

The issue is that after I run all the code the gridview never comes out of edit mode so my page just hangs.

Any help would be appreciated.


Updating Database with gridview control


I am sure I am not the first to ask this question but I cannot find an answer in these or any other forums. I guess I am not wording the question right.

In short I have a gridview populated but a database via an SQLDatasource. I have an Edit column in the datagrid and an updatequery in the datasource. When the Edit is click the line goes into edit mode, the user then clicks Update and I get an error. 

Could not find control 'DropDownList1' in ControlParameter 'Frequency'.

The only complication is that there is a drop down control when the "EDIT" column is selected. The dropdownlist gets it list from another SQLDatasource. This all works fine.

Here is the code snip:

        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateEditButton="True" 

            AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend