0

我想一次选择多条记录并通过按钮更新它们

我在互联网上搜索它总是 cs,我想要 vb.net

我做了我的网格视图如下

<asp:GridView ID="GridView1" runat="server" AutoGenerateCheckboxColumn="True"
CheckboxColumnIndex="0" AllowSorting="true" 
                    AutoGenerateColumns="False" DataKeyNames="USER_ID" 
                    DataSourceID="SqlDataSource1StudentActivList" CellPadding="2">
                    <Columns>

                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox1" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>



                        <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                            SortExpression="FirstName" />
                        <asp:BoundField DataField="LastName" HeaderText="LastName" 
                            SortExpression="LastName" />
                        <asp:BoundField DataField="MiddleName" HeaderText="MiddleName" 
                            SortExpression="MiddleName" />
                        <asp:BoundField DataField="ProgramCODE" HeaderText="ProgramCODE" 
                            SortExpression="ProgramCODE" />
                        <asp:BoundField DataField="USER_NAME" HeaderText="USER_NAME" 
                            SortExpression="USER_NAME" />
                        <asp:BoundField DataField="USER_Email" HeaderText="USER_Email" 
                            SortExpression="USER_Email" />
                        <asp:BoundField DataField="MajorNameInEnglish" HeaderText="MajorNameInEnglish" 
                            SortExpression="MajorNameInEnglish" />
                        <asp:BoundField DataField="GivenStudentID" HeaderText="GivenStudentID" 
                            SortExpression="GivenStudentID" />
                        <asp:BoundField DataField="accepted" HeaderText="accepted" 
                            SortExpression="accepted" />
                        <asp:BoundField DataField="Gender" HeaderText="Gender" 
                            SortExpression="Gender" />
                        <asp:BoundField DataField="USER_ID" HeaderText="USER_ID" ReadOnly="True" 
                            SortExpression="USER_ID" />
                    </Columns>
                    <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                </asp:GridView>



                <asp:SqlDataSource ID="SqlDataSource1StudentActivList" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:mydbConnectionString %>" 
                    SelectCommand="SELECT DISTINCT [FirstName], [LastName], [MiddleName], [ProgramCODE], [USER_NAME], [USER_Email], [MajorNameInEnglish], [GivenStudentID], [accepted], [Gender], [USER_ID] FROM [DIP_StudentsActivationList]">
                </asp:SqlDataSource>
                <p><asp:Label ID="lblSelection" runat="server" /></p>
<asp:Button ID="btupdate" runat="server" Text="Update" />

这是 VB 代码(转换后的)这不是我想要的,但我想我可以处理它

        Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Public Partial Class _Default 
Inherits System.Web.UI.Page 
Protected Sub Page_Load(sender As Object, e As EventArgs)
  If MultiSelectGridView1.SelectedDataKeys.Count > 0 Then 
  lblSelection.Text = "You selected employees: "   
For Each k As DataKey In MultiSelectGridView1.SelectedDataKeys    
lblSelection.Text += k.Value.ToString() & ", "   
Next
   lblSelection.Text = lblSelection.Text.TrimEnd(","C, " "C)  
Else
   lblSelection.Text = "No employees selected"  
End If 
End Sub
End Class

我想通过单击按钮更改我的数据库中的接受状态

请有任何帮助

4

0 回答 0