用于内联复选框编辑和插入vb.net的asp.net语法

时间:2012-10-15 16:08:04

标签: asp.net vb.net checkbox

我可以对datalist控件的语法使用一些帮助,我已经为两个字段添加了两个复选框。可以在“插入”或“编辑”模式下设置每个字段。

如何在不自定义编码后面代码中的进程的情况下,使用“插入和更新”向导来读取这些值?

这是ASP ..

<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
     AutoGenerateRows="False" CellPadding="4" DataKeyNames="keyID" 
     DataSourceID="SqlDataSource1" Font-Names="Verdana" ForeColor="#333333" 
     GridLines="Horizontal" Height="50px" Width="340px">
     <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" 
      PageButtonCount="5" />
     <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
     <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
     <RowStyle BackColor="#EFF3FB" />
     <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" Width="160px" />
     <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
     <Fields>
          <asp:BoundField DataField="keyID" HeaderText="keyID" InsertVisible="False" 
               ReadOnly="True" SortExpression="keyID" />
          <asp:BoundField DataField="typeOfDriver" HeaderText="Type Of Driver:" 
               SortExpression="typeOfDriver" />
          <asp:TemplateField HeaderText="Active Type:" SortExpression="activeType">
               <EditItemTemplate>
                    <asp:CheckBox ID="Checkbox1" runat="server"  Text='<%# Eval("activeType") %>'></asp:CheckBox>
               </EditItemTemplate>
               <InsertItemTemplate>
                   <asp:CheckBox ID="Checkbox2" runat="server"  Text='<%# Eval("activeType") %>' Checked="True"></asp:CheckBox>&nbsp;True
               </InsertItemTemplate>
               <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("activeType") %>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>
           <asp:TemplateField HeaderText="Visible in GUI:" SortExpression="visible">
               <EditItemTemplate>
                   <asp:CheckBox ID="Checkbox3" runat="server"  Text='<%# Bind("visible") %>'></asp:CheckBox>
               </EditItemTemplate>
               <InsertItemTemplate>
                   <asp:CheckBox ID="Checkbox4" runat="server"  Text='<%# Bind("visible") %>' Checked="True"></asp:CheckBox>&nbsp;True      
               </InsertItemTemplate>
               <ItemTemplate>
                   <asp:Label ID="Label1" runat="server" Text='<%# Bind("visible") %>'></asp:Label>
           </ItemTemplate>
       </asp:TemplateField>
       <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
    </Fields>
    <HeaderStyle BackColor="#99CCFF" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#FFFF99" Width="260px" />
    <AlternatingRowStyle BackColor="White" />
</asp:DetailsView>

1 个答案:

答案 0 :(得分:1)

你看到了这个吗? Working with the DataList Control

这也是一个很好的例子:How to edit/delete records using Datalist