Issues with QueryStrings / GridViews

Sean Braudrick posted at 08-May-08 10:29
I have a page that relies entirely on a QueryString being passed to it in order to list data in two GridViews. The problem is that most of the time it works as designed, but for some reason the SQLsource not getting the data returned that it needs to fill the GridViews.

The data source is SQL 2000, the key field is type nvarchar(50) and it is filled using the newid() function. I'm fairly certain that the problem exists with the SQLsources for the GridViews because I have some code that runs on Page_Load that also relies on the QueryString and it seems to run perfectly. (It calls back to the database, checks the value of a field, and then redirects if approriate.

I've run SQL Profiler and can see the traffic and everything looks right to me, I can tell no difference between what is being passed for a page that loads successfully and one that doesn't.

Strangely enough, I can use the key field and query the table from within the SQL Enterprise manager and get a correct result every time, but if I run the statement I get from the Profiler, it will fail sometimes but succeed most of the time.

Here is the command I'm getting from the Profiler:

exec sp_executesql N'SELECT [WebID], [SONum], [RevID], [Salesperson], [Customer], [ApprovalSubmitted], [OrderStat], [PONum] FROM [ApprovalsOrderStat] WHERE ([WebID] = @WebID)', N'@WebID nvarchar(36)', @WebID = N'03225C4F-AA7D-4C0E-B46E-AA742D4FD52C'

Here is the code for the GridView & SQLsource:

[code type="VB.NET"]
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4"
                DataSourceID="Revisions" Font-Size="Small" ForeColor="#333333" GridLines="None">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:BoundField DataField="SONum" HeaderText="SONum" SortExpression="SONum" />
                    <asp:BoundField DataField="RevID" HeaderText="RevID" SortExpression="RevID" />
                    <asp:BoundField DataField="RevTime" HeaderText="RevTime" SortExpression="RevTime" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                </Columns>
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#999999" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
            <asp:SqlDataSource ID="Revisions" runat="server" ConnectionString="<%$ ConnectionStrings:DealerSchedOrdDataConnectionString2 %>"
                SelectCommand="SELECT [WebID], [SONum], [RevID], [RevTime], [Description] FROM [RevisionView] WHERE ([WebID] = @WebID)">
                <SelectParameters>
                    <asp:QueryStringParameter Name="WebID" QueryStringField="WebID" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
[/code]



Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Issues with QueryStrings / GridViews - Sean Braudrick  08-May-08 10:29:54 AM
      check this.. - santhosh kapa  08-May-08 10:47:09 AM
          I don't think this will work for me - Sean Braudrick  08-May-08 11:19:26 AM
          Resolved - Sean Braudrick  08-May-08 11:36:00 AM
              cheers - santhosh kapa  08-May-08 11:39:16 AM
View Posts