Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
binding to a table with Integer Key column
posted

I am using version 2011.1.

I am using webdatagrid to display a table which has a primary key column , EntityID , of integer type.

I bind the datagrid using an <asp:sqldatasource>.

I am getting an error:

The default value string, , for column EntityID cannot be converted to the correct type, System.Int32

The stored procedure to return the table data does not have a parameter.  It is just a simple select statement.

I do not have a problem when the primary key column is of string type.

In my sqldatasource, I tried various alternatives, including and excluding the following line:

<selectparameters></selectparameters>

but it is still not working.


I am wondering if there is anything special about binding to a grid with a integer primary key.

Below is my aspx code.

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/EntityExplorer.Master" CodeBehind="EntitySubprogram.aspx.cs" Inherits="EPEDIS_Entity_Explorer.Admin.Reference.EntitySubprogram" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<asp:content ID="Content1" ContentPlaceHolderID="cphHead" runat="server">
</asp:content>
<asp:content ID="Content2" ContentPlaceHolderID="cphMain" runat="server">
   <ig:webdatagrid ID="wdg" runat="server" Height="500px" Width="975px" AutoCRUD="true"
        AutoGenerateColumns="False" DataKeyFields="EntityID" DataSourceID="SqlDataSource1"
      DataMember="DefaultView" >
      <Columns>
         <ig:BoundDataField DataFieldName="EntityID" Key="EntityID" width="60px" datatype="Int32" >
          <Header Text="Entity ID" />
         </ig:BoundDataField>
        <ig:BoundDataField DataFieldName="programCode" Key="programCode" width="80px" datatype="string">
          <Header Text="Program Code" />
        </ig:BoundDataField>
        <ig:BoundDataField DataFieldName="region" Key="region" width="120px">
          <Header Text="region" />
        </ig:BoundDataField >
     </Columns>
      <Behaviors>
        <ig:EditingCore>
          <editingclientevents rowsdeleting="confirm_delete" />
          <Behaviors>
            <ig:CellEditing>
              <columnsettings>
                <ig:editingcolumnsetting columnkey="EntityID" readonly="True" />
              </columnsettings>
              <EditModeActions EnableOnKeyPress="True" MouseClick="Single" />
            </ig:CellEditing>
            <ig:rowdeleting />
            <ig:RowAdding>
              <columnsettings>
                <ig:rowaddingcolumnsetting columnkey="EntityID" />
              </columnsettings>
              <EditModeActions MouseClick="Single" EnableOnActive="True" enableonkeypress="True">
              </EditModeActions>
            </ig:RowAdding>
          </Behaviors>
        </ig:EditingCore>
        <ig:Activation />
        <ig:selection cellclickaction="Row" rowselecttype="Single">
        </ig:selection>
        <ig:rowselectors>
        </ig:rowselectors>
      </Behaviors>
    </ig:webdatagrid>
    <asp:sqldatasource ID="SqlDataSource1" runat="server"
      ConnectionString="<%$ ConnectionStrings:EpedisConnectionString %>"
      Deletecommand="Delete_Entity" Deletecommandtype="StoredProcedure"
      InsertCommand="Update_Entity" InsertCommandType="StoredProcedure"
      SelectCommand="Get_Entity" selectcommandtype="StoredProcedure"
      UpdateCommand="Update_Entity" UpdateCommandType="StoredProcedure">
        <UpdateParameters>
            <asp:Parameter Name="EntityID" Type="Int32"/>
            <asp:Parameter Name="programCode" Type="String" />
            <asp:Parameter Name="region" Type="String" />
       </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="EntityID" Type="Int32" />
            <asp:Parameter Name="programCode" Type="String" />
            <asp:Parameter Name="region" Type="String" />
        </InsertParameters>
        <deleteparameters>
          <asp:Parameter Name="EntityID" Type="Int32" />
        </deleteparameters>
    </asp:sqldatasource>
  <asp:button ID="btnUpdate" runat="server" Text="Update"  cssclass="btn_3D_Bold" />

  </script>
</asp:content>

Parents Reply Children
No Data