asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
在datagrid中,我们可能会需要实现这种功能——列的单选,本身datagrid提供了select命令可以实现这种功能,而我们往往又习惯于RadioButton来实现,下面就谈谈怎么样用RadioButtonList来实现。

1、我们将datagrid的第一列设置为模板列,并加入RadioButtonList

2、在datagrid.databind();后加入以下代码

//将第一列第一单元格的RowSpan设置为DataGrid的总列数

DataGrid.Items[0].Cells[0].RowSpan=DataGrid.Items.Count;
for (int i=1;i<DataGrid.Items.Count;++i)
{
DataGrid.Items[i].Cells[0].Visible=false; //从第二列开始隐藏第一个单元格
}

//将第一列第一个单元格里的RadioButtonList按照DataGrid的总列数进行列添加

for (int i=0;i<DataGrid.Items.Count;++i)
{
ListItem ss=new ListItem("","1");
((RadioButtonList)DataGrid.Items[0].Cells[0].Controls[1]).Items.Add(ss);
posted on 2006-04-03 14:03 汪杰 阅读(165) 评论(0)  编辑 收藏 引用 所属分类: hengxing网站js
只有注册用户登录后才能发表评论。

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 459271
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜