GridView will not update underlying data source

Posted by John Christensen on Stack Overflow See other posts from Stack Overflow or by John Christensen
Published on 2008-09-09T19:02:14Z Indexed on 2010/04/19 12:03 UTC
Read the original article Hit count: 255

Filed under:
|
|

So I'm been pounding on this problem all day. I've got a LinqDataSource that points to my model and a GridView that consumes it. When I attempt to do an update on the GridView, it does not update the underlying data source. I thought it might have to do with the LinqDataSource, so I added a SqlDataSource and the same thing happens. The aspx is as follows (the code-behind page is empty):

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
      ConnectionString="Data Source=devsql32;Initial Catalog=Steam;Persist Security Info=True;" 
      ProviderName="System.Data.SqlClient" 
      SelectCommand="SELECT [LangID], [Code], [Name] FROM [Languages]" UpdateCommand="UPDATE [Languages] SET [Code]=@Code WHERE [LangID]=@LangId">
  </asp:SqlDataSource>
  <asp:GridView ID="_languageGridView" runat="server" AllowPaging="True" 
      AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="LangId" 
      DataSourceID="SqlDataSource1">
      <Columns>
          <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
          <asp:BoundField DataField="LangId" HeaderText="Id" ReadOnly="True" />
          <asp:BoundField DataField="Code" HeaderText="Code" />
          <asp:BoundField DataField="Name" HeaderText="Name" />
      </Columns>
  </asp:GridView>
  <asp:LinqDataSource ID="_languageDataSource" ContextTypeName="GeneseeSurvey.SteamDatabaseDataContext" runat="server" TableName="Languages" EnableInsert="True" EnableUpdate="true" EnableDelete="true">
 </asp:LinqDataSource>

What in the world am I missing here? This problem is driving me insane.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about linq-to-sql