Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 循环通过gridview获取错误_Sql_Asp.net_Gridview - Fatal编程技术网

Sql 循环通过gridview获取错误

Sql 循环通过gridview获取错误,sql,asp.net,gridview,Sql,Asp.net,Gridview,我有一个gridview,我正试图循环使用它来获取要更新并存储在数据库中的值。Gridview代码: <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" Width="1020px" EnableTheming="True" PageSize="25" CellPadding="4"

我有一个gridview,我正试图循环使用它来获取要更新并存储在数据库中的值。Gridview代码:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" 
                Width="1020px" EnableTheming="True" PageSize="25" CellPadding="4" 
                ForeColor="#333333" >
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:BoundField DataField="Column1" HeaderText="Col1" ReadOnly="True" >
                    <ItemStyle Width="35px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Column2" HeaderText="Col2" />
                    <asp:BoundField DataField="Column3" HeaderText="Col3" />
                    <asp:BoundField DataField="Column4" HeaderText="Col4" />
                    <asp:BoundField DataField="Column5" HeaderText="Col5" />
                    <asp:TemplateField HeaderText="Col6">
                        <EditItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Column6") %>'></asp:Label>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text="$"></asp:Label>&nbsp;
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Column6", "{0:f}") %>' CssClass="boxright"></asp:TextBox>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                    </asp:TemplateField>
                    <asp:BoundField DataField="Column7" ReadOnly="True" >
                    <ItemStyle Width="35px" />
                    </asp:BoundField>
                    </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#003399" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="White" />
                <PagerSettings Mode="NextPreviousFirstLast" />
                <PagerStyle BackColor="#003399" ForeColor="White" HorizontalAlign="Left" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
然而,在我的“dt(datatable)”表达式下,我不断得到那些蓝色语法错误行。。。关于如何或为什么这样做有什么想法吗?

嗯,“变量gvRow隐藏…”错误正在发生,因为您在循环外部声明了gvRow,然后在循环定义中重新声明了它

Dim gvRow As GridViewRow    ' First declaration
Dim str As String = ""
For Each gvRow As GridViewRow In gv_Budgets.Rows    ' Skip the "As GridViewRow here
另一个错误来自您的表达式:

dt = dal.ExecuteStoredProc( ...

我假设(因为您没有列出它)dt是某个DataTable类型的全局变量。在本例中,存储过程似乎正在返回字符串并试图将其插入到datatable对象中。确保存储过程返回有效的数据表。同时,您可以尝试将结果插入到字符串中,以使其正常工作,直到您能够解决该问题。

它报告的确切错误是什么?如果您在错误列表窗口中查看,它会给出错误的确切错误。类型为“String”的值不能转换为“System.Data.DataTable”
dt = dal.ExecuteStoredProc( ...