网格视图中的复选框列表 [英] Checkbox list in the gridview

查看:56
本文介绍了网格视图中的复选框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gridview的columns集合中添加一个复选框列表.如何为它增加价值..我尝试了以下方法,但没有成功.请帮忙.

How to bring a checkboxlist in the columns collections of the gridview. How to add values to it..I tried it the following way but wasnt a success. Please help.

<asp:GridView ID="GridView1" runat="server">
        <Columns>
        <asp:TemplateField>
        <ItemTemplate>
        <asp:CheckBoxList runat="server" ID="mycheckboxlst" DataValueField="city"></asp:CheckBoxList>
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>
        </asp:GridView>

推荐答案

请参阅 THIS [ ^ ]简洁的文章将帮助您.

谢谢
see THIS[^] neat article will help you towards.

Thanks


您可以添加SqlDataSource.配置它,以便它从数据库中获取所需的列表.然后将其附加到CheckBoxList,如下所示.
You can add a SqlDataSource. Configure it so that it fetches your desired list from DB. Then attach it to the CheckBoxList as shown below.
<asp:CheckBoxList runat="server" ID="mycheckboxlst" DataValueField="City"

        DataSourceID="SqlDataSource1" DataTextField="FirstName"></asp:CheckBoxList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

        ConnectionString="<%


ConnectionStrings:SampleDatabaseConnectionString %> ; " span> SelectCommand =" 选择*来自[CustomerInfo]" < /asp:SqlDataSource >
ConnectionStrings:SampleDatabaseConnectionString %>" SelectCommand="SELECT * FROM [CustomerInfo]"></asp:SqlDataSource>



请注意,您需要设置DataValueFieldDataTextField属性以绑定每个复选框的文本和值.



Note that you need to set DataValueField and DataTextField properties to bind the text and value for each check box.


这篇关于网格视图中的复选框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆