CheckBoxList控件基本用法 如何给DropDownList控件添加边框[整理]
来源:互联网 发布:2016年开淘宝店晚不晚 编辑:程序博客网 时间:2024/05/20 15:41
1.绑定数据
this.lngCatalogID.DataSource = dt; //这里我绑到DataTable上了.
this.lngCatalogID.DataTextField = "strCatalogName"; //前台看到的值,也就是CheckBoxList中显示出来的值
this.lngCatalogID.DataValueField = "lngCatalogID"; //这个值直接在页面上是看不到的,但在源代码中可以看到
this.lngCatalogID.DataBind();
2.获取钩选的项
foreach(ListItem li in lngCatalogID.Items)
{
if(li.Selected) //表示某一项被选中了
{
//li.Test表示看到的值,对应上面的strCatalogName
//li.Value表示看到的值对应的值.对应上面的lngCatalogID
}
}
3.设置某项为钩选状态
foreach(ListItem li in lngCatalogID.Items)
{
if(li.Value.Equals("钩选条件")) //如果li.Value值等于某值,就钩选
{
li.Selected = true; //等于true就表示钩选啦.
break;
}
}
数据绑定
checkedListBox1.DataSource=ds.Tables[0];
checkedListBox1.ValueMember="intSectionID";
checkedListBox1.DisplayMember="txtShortDesc".ToString();
数据显示
int count = checkedListBox1.Items.Count;
for (int i = 0;i<count;i++)
{
if (checkedListBox1.GetItemChecked(i))
{
MessageBox.Show(checkedListBox1.Items[i].ToString());
}
}
DataGrid中全选
foreach(DataGridItem thisItem in DataGridLogininfo.Items)
{
((CheckBox)thisItem.Cells[0].Controls[1]).Checked = CheckBox2.Checked;
}
反向选择
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.GetItemChecked(i))
{
checkedListBox1.SetItemChecked(i, false);
}
else
{
checkedListBox1.SetItemChecked(i, true);
}
}
在控件前添加如下蓝色代码(这里添加的是灰色边框):
<span style="border-right: gray 1px solid; border-top: gray 1px solid;
border-left: gray 1px solid; border-bottom: gray 1px solid;">
<asp:DropDownList ID="ddlSearch" runat="server">
<asp:ListItem Value="title">标题</asp:ListItem>
<asp:ListItem Value="content">内容</asp:ListItem>
<asp:ListItem Value="author">作者</asp:ListItem>
</asp:DropDownList>
</span>
- CheckBoxList控件基本用法 如何给DropDownList控件添加边框[整理]
- 如何给DropDownList控件添加边框[整理]
- 如何给DropDownList控件添加边框
- CheckBoxList控件基本用法
- DropDownList控件的基本用法
- Andriod 给控件添加边框
- checkboxlist控件用法
- 通过shape给控件添加边框
- Android 给控件添加边框阴影
- 给控件添加虚线边框(UIBezierPath)
- 给控件添加圆角边框
- Android通过xml给控件添加边框
- DataSet绑定ListBox、DropDownList、RadioButtonList、CheckBoxList控件
- DataSet绑定ListBox、DropDownList、RadioButtonList、CheckBoxList控件
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- Flex中image控件如何添加边框
- 给服务器端DropDownList控件添加客户端onchange事件
- 给服务器端DropDownList控件添加客户端onchange事件
- left join/right join/inner join操作演示
- 在SQL Server中快速删除重复记录(多图)
- 批处理文件中是否可以用变量
- Java中对文件的操作
- 出来贵地,只为学习,愿与大家共同进步!
- CheckBoxList控件基本用法 如何给DropDownList控件添加边框[整理]
- DataGrid中日期格式化方法
- Java学习之路:少走弯路,就是捷径
- 注意Windows注册表里加载的病毒和流氓软件!
- 编写高性能Web应用程序的10个技巧
- 随笔
- 关于.net中的mutex
- Nothing
- sql 技术