1

我想遍历gridview并查看是否选中了复选框然后使用ASP .net gridview获取第一列值代码看起来正确...但是当我将else语句添加到代码中然后放入else中时会发出警报然后当我在gridview中检查并单击button1时,他们向我显示警报而不是执行命令我会尝试这个但它不起作用:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        For i As Integer = 0 To DossierGV.Rows.Count - 1
            If DirectCast(DossierGV.Rows(i).Cells(0).FindControl("CheckBox1"), CheckBox).Checked = True Then
                execSQL("update OFPPT_Envoyer set vue = '1' where ID_Dossier = " & (DossierGV.Rows(i).Cells(1).Text), "e")
            End If
        Next
    End Sub

这是 gridview :

 &nbsp;<asp:Button ID="Button1" runat="server" Text="Vue" />
           <asp:GridView ID="DossierGV" runat="server" AllowSorting="True" 
               AutoGenerateColumns="False" DataKeyNames="ID_Dossier" 
               DataSourceID="SqlDataSource1">
               <Columns>
                <asp:TemplateField HeaderText="Choisir">
                       <EditItemTemplate>
                           <asp:CheckBox ID="CheckBox1" runat="server" />
                       </EditItemTemplate>
                       <ItemTemplate>
                           <asp:CheckBox ID="CheckBox1" runat="server" />
                       </ItemTemplate>
                   </asp:TemplateField>
                   <asp:BoundField DataField="ID_Dossier" HeaderText="ID_Dossier" ReadOnly="True" 
                       SortExpression="ID_Dossier" />
                   <asp:BoundField DataField="I ....................
..............................
4

1 回答 1

0

问题是因为我Me.DataBind()在加载事件中添加了 (( ))

于 2012-07-28T16:19:14.270 回答