| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 951 人关注过本帖
标题:[求助]DataGrid中绑定RedioButton控件问题???
只看楼主 加入收藏
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
 问题点数:0 回复次数:7 
[求助]DataGrid中绑定RedioButton控件问题???
我在DataGrid中绑定了四个RedioButton控件,我想要实现选中哪一个我就把那一个所对应的值更新到数据库,应该怎么样实现呢?请各位不吝赐教,先谢谢了!
搜索更多相关主题的帖子: DataGrid中 绑定 RedioButton 控件 数据库 
2007-05-15 19:22
guming
Rank: 4
等 级:业余侠客
威 望:5
帖 子:329
专家分:277
注 册:2006-11-9
收藏
得分:0 

想必在RadionButton所在行里应该有按钮的吧,设置该按钮的CommandName属性如CommandName="JUSTGO"。再在按钮OnClick事件中按ItemIndex在DataGrid中查找RadioButton控件,,,再将它的值更新到数据库。。

private btnok_Click(Object sender,DataGridCommandEventArgs e)
{
if(e.CommandName=="JUSTGO")
{
DataGridItem rdo=你的DataGridID.Items[(int)e.Item.ItemIndex];//先按ItemIndex查找到按钮所在的行
RadionButton rdobtn=(RadionButton)rdo.FindControl("你所设的RadionButton控件的ID");//在找到的行中查找RadioButton控件。
string t=rdobtn.Text;//获得RadioButton的值,再将t的值更新到数据库
}
}

[此贴子已经被作者于2007-5-15 20:04:23编辑过]


不想停留。。。
2007-05-15 20:02
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
得分:0 
没有,在RadionButton所在行里没有有按钮,按钮是在DataGrid外边。

Face up to life with smiles no matter what happens
2007-05-15 20:13
guming
Rank: 4
等 级:业余侠客
威 望:5
帖 子:329
专家分:277
注 册:2006-11-9
收藏
得分:0 
将RadionButton的AutoPostBack属性设为true,在它的触动事件里写啊

不想停留。。。
2007-05-15 20:22
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
得分:0 
老兄,你能否给点代码我看一下,因为我以前确实没有做过这方面相关的项目。

Face up to life with smiles no matter what happens
2007-05-15 20:39
guming
Rank: 4
等 级:业余侠客
威 望:5
帖 子:329
专家分:277
注 册:2006-11-9
收藏
得分:0 
你是不是想,选中某一行的RadionButton,再点击DataGrid外面的按钮,就将它的Text属性更新到数据库啊,??
void btnok_Click(Object Sender,System.EventArgs e)
{
bool IsChecked=false;
foreach(DataGridItem rdoitem in 你的DataGridID.Items)
{
IsChecked=rdoitem.FindControl("你的RadionButton控件ID").Checked;
if(IsChecked)
{
DataGridItem rdo=你的DataGridID.Items[(int)rdoitem.ItemIndex];
RadionButton rdobtn=(RadionButton)rdo.FindControl("你所设的RadionButton控件的ID");
string t=rdobtn.Text;//获得RadioButton的值,再将t的值更新到数据库
//接下去就是更新数据库的命令等操作
}
}
}



不想停留。。。
2007-05-15 20:59
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
得分:0 

谢谢你,我先试一试。


Face up to life with smiles no matter what happens
2007-05-15 22:06
tel1982
Rank: 3Rank: 3
来 自:水星
等 级:新手上路
威 望:8
帖 子:852
专家分:0
注 册:2006-10-21
收藏
得分:0 
以下是引用guming在2007-5-15 20:59:16的发言:
你是不是想,选中某一行的RadionButton,再点击DataGrid外面的按钮,就将它的Text属性更新到数据库啊,??
void btnok_Click(Object Sender,System.EventArgs e)
{
bool IsChecked=false;
foreach(DataGridItem rdoitem in 你的DataGridID.Items)
{
IsChecked=rdoitem.FindControl("你的RadionButton控件ID").Checked;
if(IsChecked)
{
DataGridItem rdo=你的DataGridID.Items[(int)rdoitem.ItemIndex];
RadionButton rdobtn=(RadionButton)rdo.FindControl("你所设的RadionButton控件的ID");
string t=rdobtn.Text;//获得RadioButton的值,再将t的值更新到数据库
//接下去就是更新数据库的命令等操作
}
}
}


这个属性好像没有。


Face up to life with smiles no matter what happens
2007-05-16 13:44
快速回复:[求助]DataGrid中绑定RedioButton控件问题???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012355 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved