User-2066415806 posted
This had me stumped and frustrated for awhile but I finally figured it out.
My GridView was not updating like so many others have been having problems with, I searched the forums and implemented all the suggestions to fix it to no avail. To start out, I'm using VS 2005, I have a page set up with a gridview and my datasource
is Access. Everything was displaying fine but the updates were not taking hold, all my parameters were in place and in the proper order. I actually had two pages in the site with gridviews connected to the same .mdb
datasource but different tables. One worked fine, the other didn't...so this made it fairly easy to troubleshoot. Getting to the point...
I was missing a critcal property in my GridView tag....DataKeyNames=My Primary Key Field
<
asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
CellPadding="4"
DataKeyNames="ID"
DataSourceID="AccessDataSource2"
ForeColor="#333333"
GridLines="None"
AllowPaging="True"
AllowSorting="True"
PageSize="20">
My working table had this property because I brought it in from the Server Explorer which automatically created the gridview and had the property set in the GridView tag. My non-working table was added from
the ToolBox and never created this DataKeyNames property in the tag.
How was I supposed to know it needed to be there? Well, I know now!
Hope this will help someone, I see alot of posts about tables not updating and this was my fix.