簡體   English   中英

帶有數據綁定下拉列表的gridview按鈕失敗

[英]gridview button with databound drop down fails

我有一個帶有按鈕的gridview,單擊該按鈕時,它會觸發rowcommand過程並將新行添加到數據庫中。 一切正常,直到我向網格視圖添加數據綁定下拉列表。

使用數據綁定下拉列表,頁面可以很好地加載,但是當我單擊按鈕時,錯誤顯示為“ Internet Explorer無法顯示網頁”。 這是我的代碼

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand"
    DataSourceID="SqlDataSource1">
    <Columns>
        <asp:ButtonField CommandName="insertNew"  
    Text="Button" />
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Button ID="btnAdd" runat="server" CommandName="insertNew"
                CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                Text="Add" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField></asp:TemplateField>
    </Columns>
</asp:GridView>

這是我按下按鈕時運行的代碼。

   Protected Sub GridView1_RowCommand(ByVal sender As Object, _
   ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
    If (e.CommandName = "insertNew") Then

        Dim index As Integer = Convert.ToInt32(e.CommandArgument)
        MsgBox(index)
    End If
End Sub

問題出在MsgBox行中。 Web應用程序中不支持MsgBox(index)

請刪除MsgBox(index) ,此問題將得到解決,因為該功能僅在Windows應用程序中受支持。

我只需要把它放到system.web web.config文件中

<httpRuntime maxRequestLength="32768" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM