2011-08-22 66 views
0

我有一个按钮的gridview,当点击按钮时,它触发一个rowcommand过程,并添加一个新的行到数据库。一切正常,直到我添加一个databound下拉列表到gridview。gridview按钮与数据绑定下拉失败

使用数据绑定下拉列表,页面加载正常,但是当我单击按钮时,错误显示为“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 

回答

0

问题出在MsgBox这一行。 Web应用程序不支持MsgBox(index)

请删除MsgBox(index),问题将被修复,因为该功能仅在Windows应用程序中受支持。

+0

我只是在那里在我的本地,它确实工作。它不在那里。 – dan

+0

当它失败的网格中有一个数据绑定下拉列表时,它并没有什么区别。顺便说一句,你可以在本地使用msgbox。 – dan

+0

这不会在服务器上工作呢? –

0

我不得不把这个进入的System.Web web.config文件

<httpRuntime maxRequestLength="32768" />