GridView and SQLDataSource

Discussion in 'ASP .Net Datagrid Control' started by CBKowitz, Mar 7, 2007.

  1. CBKowitz

    CBKowitz Guest

    Trying a simple (Ha Ha) gridview and SQLDatasource combination. When I run
    the page nothing shows. Here's the code:

    <%@ Page Language="vb" AutoEventWireup="false"
    Inherits="TestSystemSecurity.SecurityFormList" enableViewState="True"
    CodeFile="SecurityFormList.aspx.vb" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>Security Form List</title>
    <%
    writeLoadSteps()
    %>
    <script src="numjs.js"></script>
    <script language="javascript">

    window.name = "SecFormList"

    function submitIt()
    {
    document.frmSecurityFormList.recAdded.value = 1;

    document.frmSecurityFormList.submit();
    }
    </script>
    </HEAD>
    <body onload="loadSteps()">
    <div align="center">
    <form id="frmSecurityFormList" method="post" runat="server">
    <INPUT value="0" type="hidden" name="recAdded">
    <asp:label id="lblTitle" runat="server" Height="24px" SkinID=DB_14B
    Width="761px">
    View / Update Security Form List
    </asp:label>
    <br>
    <br>

    <asp:GridView ID="gvSecurityList" runat="server" Width="1005px"
    SkinID="RainyDay8" PageSize="15" AutoGenerateColumns=False CellPadding="3"
    AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
    DataSourceID="sqlDSFormList" AllowPaging="True">
    <Columns>
    <asp:BoundField DataField="ID" SortExpression="ID"
    ReadOnly="True" HeaderText="ID">
    <HeaderStyle Width="30px"></HeaderStyle>
    </asp:BoundField>
    <asp:BoundField DataField="FORM NAME" SortExpression="FORM NAME"
    HeaderText="Form Name">
    <HeaderStyle Width="250px"></HeaderStyle>
    </asp:BoundField>
    <asp:BoundField DataField="CONTROL NAME" SortExpression="CONTROL
    NAME" HeaderText="Control Name">
    <HeaderStyle Width="150px"></HeaderStyle>
    </asp:BoundField>
    <asp:BoundField DataField="DESCRIPTION"
    SortExpression="DESCRIPTION" HeaderText="Description">
    <HeaderStyle Width="300px"></HeaderStyle>
    </asp:BoundField>
    <asp:BoundField DataField="ROLES" SortExpression="ROLES"
    HeaderText="Security Roles">
    <HeaderStyle Width="150px"></HeaderStyle>
    </asp:BoundField>
    </Columns>
    </asp:GridView>

    <br>
    <asp:SqlDataSource ID="sqlDSFormList" runat="server"
    ConnectionString="Connection String Not Shown"
    DeleteCommand="spDeleteSecurityFormListTable"
    DeleteCommandType="StoredProcedure"
    InsertCommand="spInsertSecurityFormListTable"
    InsertCommandType="StoredProcedure"
    ProviderName="System.Data.SqlClient"
    SelectCommand="spSelectSecurityFormListTable"
    SelectCommandType="StoredProcedure"
    UpdateCommand="spUpdateSecurityFormListTable"
    UpdateCommandType="StoredProcedure">
    <DeleteParameters>
    <asp:parameter Name="IdxId" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
    <asp:parameter Name="FormName" Type="String" />
    <asp:parameter Name="ControlName" Type="String" />
    <asp:parameter Name="Description" Type="String" />
    <asp:parameter Name="Roles" Type="String" />
    <asp:parameter Name="IdxId" Type="Int32" />
    </UpdateParameters>
    <SelectParameters>
    <asp:SessionParameter DefaultValue="-1" Name="IdxId"
    SessionField="IdxID" Type="Int32" />
    <asp:SessionParameter DefaultValue="" Name="Role"
    SessionField="ViewRole" Type="String" />
    </SelectParameters>
    <InsertParameters>
    <asp:parameter Name="FormName" Type="String" />
    <asp:parameter Name="ControlName" Type="String" />
    <asp:parameter Name="Description" Type="String" />
    <asp:parameter Name="Roles" Type="String" />
    </InsertParameters>
    </asp:SqlDataSource>
    <br>
    <asp:ImageButton id="btnExit" runat="server"
    ImageUrl="images/exit.gif"></asp:ImageButton>

    <asp:ImageButton id="btnAdd" runat="server"
    ImageUrl="images/add.gif"></asp:ImageButton>
    </form>
    </div>
    </body>
    </HTML>
    CBKowitz, Mar 7, 2007
    #1
    1. Advertising

  2. CBKowitz

    Riki Guest

    Since you're using two session parameters in your select command,
    are you sure they have been initialized?

    Somehow, your select statement is producing zero records, that's why the
    gridview doesn't show up.

    -- Riki

    CBKowitz wrote:
    > Trying a simple (Ha Ha) gridview and SQLDatasource combination. When
    > I run the page nothing shows. Here's the code:
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Inherits="TestSystemSecurity.SecurityFormList" enableViewState="True"
    > CodeFile="SecurityFormList.aspx.vb" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>Security Form List</title>
    > <%
    > writeLoadSteps()
    > %>
    > <script src="numjs.js"></script>
    > <script language="javascript">
    >
    > window.name = "SecFormList"
    >
    > function submitIt()
    > {
    > document.frmSecurityFormList.recAdded.value = 1;
    >
    > document.frmSecurityFormList.submit();
    > }
    > </script>
    > </HEAD>
    > <body onload="loadSteps()">
    > <div align="center">
    > <form id="frmSecurityFormList" method="post" runat="server">
    > <INPUT value="0" type="hidden" name="recAdded">
    > <asp:label id="lblTitle" runat="server" Height="24px"
    > SkinID=DB_14B Width="761px">
    > View / Update Security Form List
    > </asp:label>
    > <br>
    > <br>
    >
    > <asp:GridView ID="gvSecurityList" runat="server" Width="1005px"
    > SkinID="RainyDay8" PageSize="15" AutoGenerateColumns=False
    > CellPadding="3" AutoGenerateDeleteButton="True"
    > AutoGenerateEditButton="True" DataSourceID="sqlDSFormList"
    > AllowPaging="True"> <Columns>
    > <asp:BoundField DataField="ID" SortExpression="ID"
    > ReadOnly="True" HeaderText="ID">
    > <HeaderStyle Width="30px"></HeaderStyle>
    > </asp:BoundField>
    > <asp:BoundField DataField="FORM NAME" SortExpression="FORM
    > NAME" HeaderText="Form Name">
    > <HeaderStyle Width="250px"></HeaderStyle>
    > </asp:BoundField>
    > <asp:BoundField DataField="CONTROL NAME"
    > SortExpression="CONTROL NAME" HeaderText="Control Name">
    > <HeaderStyle Width="150px"></HeaderStyle>
    > </asp:BoundField>
    > <asp:BoundField DataField="DESCRIPTION"
    > SortExpression="DESCRIPTION" HeaderText="Description">
    > <HeaderStyle Width="300px"></HeaderStyle>
    > </asp:BoundField>
    > <asp:BoundField DataField="ROLES" SortExpression="ROLES"
    > HeaderText="Security Roles">
    > <HeaderStyle Width="150px"></HeaderStyle>
    > </asp:BoundField>
    > </Columns>
    > </asp:GridView>
    >
    > <br>
    > <asp:SqlDataSource ID="sqlDSFormList" runat="server"
    > ConnectionString="Connection String Not Shown"
    > DeleteCommand="spDeleteSecurityFormListTable"
    > DeleteCommandType="StoredProcedure"
    > InsertCommand="spInsertSecurityFormListTable"
    > InsertCommandType="StoredProcedure"
    > ProviderName="System.Data.SqlClient"
    > SelectCommand="spSelectSecurityFormListTable"
    > SelectCommandType="StoredProcedure"
    > UpdateCommand="spUpdateSecurityFormListTable"
    > UpdateCommandType="StoredProcedure">
    > <DeleteParameters>
    > <asp:parameter Name="IdxId" Type="Int32" />
    > </DeleteParameters>
    > <UpdateParameters>
    > <asp:parameter Name="FormName" Type="String" />
    > <asp:parameter Name="ControlName" Type="String" />
    > <asp:parameter Name="Description" Type="String" />
    > <asp:parameter Name="Roles" Type="String" />
    > <asp:parameter Name="IdxId" Type="Int32" />
    > </UpdateParameters>
    > <SelectParameters>
    > <asp:SessionParameter DefaultValue="-1" Name="IdxId"
    > SessionField="IdxID" Type="Int32" />
    > <asp:SessionParameter DefaultValue="" Name="Role"
    > SessionField="ViewRole" Type="String" />
    > </SelectParameters>
    > <InsertParameters>
    > <asp:parameter Name="FormName" Type="String" />
    > <asp:parameter Name="ControlName" Type="String" />
    > <asp:parameter Name="Description" Type="String" />
    > <asp:parameter Name="Roles" Type="String" />
    > </InsertParameters>
    > </asp:SqlDataSource>
    > <br>
    > <asp:ImageButton id="btnExit" runat="server"
    > ImageUrl="images/exit.gif"></asp:ImageButton>
    >
    > <asp:ImageButton id="btnAdd" runat="server"
    > ImageUrl="images/add.gif"></asp:ImageButton>
    > </form>
    > </div>
    > </body>
    > </HTML>
    Riki, Mar 10, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UA==?=
    Replies:
    1
    Views:
    2,200
    Michelle Hlaing
    Nov 30, 2004
  2. Henry Habermacher [MVP Access]

    GridView - Changing FilterExpression of SQLDataSource and Paging

    Henry Habermacher [MVP Access], Jan 20, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,984
    kmarchiony
    Jul 31, 2007
  3. =?Utf-8?B?RGFiYmxlcg==?=

    insert row using Gridview and SqlDataSource?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 19, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,646
    =?Utf-8?B?RGFiYmxlcg==?=
    Mar 20, 2006
  4. =?Utf-8?B?RG9ydGU=?=

    Gridview and SqlDatasource from code behind

    =?Utf-8?B?RG9ydGU=?=, Mar 30, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    24,762
    =?Utf-8?B?Y2xpY2tvbg==?=
    Mar 30, 2006
  5. phil
    Replies:
    2
    Views:
    1,101
    Shahzad Godil
    Nov 14, 2006
Loading...

Share This Page