我对VB编码的了解有限。我现在正在创建一个系统,允许客户选择他们想要的展览活动和展位号,然后预订他们想要租用的日期。
默认情况下,在 GridView 控件中可以添加复选框字段,但它只会为 1 行数据生成 1 个复选框。
正如标题中的状态,我不知道如何为数据库调用 D1、D2、D3、D4、D5、D6 和 D7 中的每个字段生成复选框,默认情况下每个字段的值为 0。现在我希望每个字段都有一个复选框,以允许客户选择他们想要保留的日期并检索他们的检查值以窃取到相应的 D1-D7 字段,检查值会将值更新为 0 到 1。
接下来,我应该如何编码将检查的值存储到数据库中?在 default.aspx 或 default.aspx.vb 中?
或任何其他建议生成复选框而不是使用gridview?
使用 GridView 的默认视图
我想要的是
我的编码:
<%@ Page Language="VB" MasterPageFile="~/MasterPageMember.master" AutoEventWireup="false" CodeFile="member_view_event_list.aspx.vb" Inherits="member_view_event_list" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style8
{
width: 46px;
}
.style9
{
}
.style10
{
width: 86px;
}
</style>
</asp:Content>
<asp:Content ID="ContentPlaceHolder2" runat="server"
contentplaceholderid="ContentPlaceHolder2">
<table width="80%">
<tr><td class="style10"> </td><td class="style8"> </td><td> </td></tr>
<tr><td class="style10">
<asp:Label ID="Label1" runat="server" Text="Select Event:"></asp:Label>
</td><td class="style8">
<asp:DropDownList ID="ddlEventList" runat="server"
DataSourceID="SqlDataSourceEvent" DataTextField="eventTitle"
DataValueField="eventID" AutoPostBack="True" Width="200">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceEvent" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT DISTINCT [eventTitle], [eventID] FROM [booth_eventinfo]">
</asp:SqlDataSource>
</td><td>
</td></tr>
<tr><td class="style10">
<asp:Label ID="Label2" runat="server" Text="Select Booth:"></asp:Label>
</td><td class="style8">
<asp:DropDownList ID="ddlBoothList" runat="server"
DataSourceID="SqlDataSourceBooth" DataTextField="boothAlias"
DataValueField="boothID" AutoPostBack="True" Width="200">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceBooth" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT [boothAlias], [boothID] FROM [booth_eventinfo] WHERE ([eventID] = @eventID)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlEventList" Name="eventID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td><td>
</td></tr>
<tr><td class="style10">
</td><td class="style8">
</td><td>
</td></tr>
<tr><td class="style9" colspan="3">
<asp:GridView ID="GridViewDay" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="SqlDataSourceDay" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="D1" HeaderText="Day1" SortExpression="D1" />
<asp:BoundField DataField="D2" HeaderText="Day2" SortExpression="D2" />
<asp:BoundField DataField="D3" HeaderText="Day3" SortExpression="D3" />
<asp:BoundField DataField="D4" HeaderText="Day4" SortExpression="D4" />
<asp:BoundField DataField="D5" HeaderText="Day5" SortExpression="D5" />
<asp:BoundField DataField="D6" HeaderText="Day6" SortExpression="D6" />
<asp:BoundField DataField="D7" HeaderText="Day7" SortExpression="D7" />
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceDay" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT [D1], [D7], [D6], [D5], [D4], [D3], [D2] FROM [booth_eventinfo] WHERE ([boothID] = @boothID)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlBoothList" Name="boothID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td></tr>
<tr><td class="style10">
</td><td class="style8">
<asp:CheckBox ID="CheckBox1" runat="server" />
</td><td>
</td></tr>
</table>
</asp:Content>