社区
C#
帖子详情
如何在DataGrid中使用RadioButton?(急,各位大哥,帮帮小弟!)
jedliu
2004-07-19 10:25:57
我想在DataGrid中加入一列RadioButton,在点击每行前面的RadioButton时,选择该行,然后做修改等处理。但我发现这些RadioButton其实是一个,对任何一行修改等于对全体修改。请帮忙!
...全文
147
6
打赏
收藏
微信扫一扫
点击复制链接
分享
举报
写回复
6 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
fogwater
2004-07-19
<asp:TemplateColumn HeaderText="选择">
<HeaderStyle Width="30px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="30px"></ItemStyle>
<ItemTemplate>
<INPUT type="Radio" onclick="OnGridClick(FaceCodeCK);" name=FaceCodeCK value='<%# DataBinder.Eval(Container.DataItem, "MaterialID") %>' >
</ItemTemplate>
</asp:TemplateColumn>
如上加一个,模版列
打赏
举报
回复
赞
anson2003
2004-07-19
哈哈!抄袭的吧!我来接分!
打赏
举报
回复
赞
csq0516
2004-07-19
<%@ Import Namespace="System.Data" %>
<%@ Page Language="C#" AutoEventWireup="True" EnableViewState = "true"%>
<HTML>
<script runat="server">
DataTable Cart;
DataView CartView;
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i < 101; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i+1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
string js = "";
js+="<script>\r\n";
js+="function ld(){\r\n";
js+="for(i=0;i<document.getElementsByName('RadioName').length;i++)\r\n";
js+="if(document.getElementsByName('RadioName')[i].value==";
js+="document.getElementById('" + rd.ClientID + "').value) ";
js+="document.getElementsByName('RadioName')[i].checked=true\r\n";
js+="}\r\n";
js+="window.onload=ld\r\n";
js+="</"+"script>\r\n";
this.RegisterStartupScript("js",js);
if (!IsPostBack)
{
ItemsGrid.DataSource = CreateDataSource();
ItemsGrid.DataBind();
}
}
void Grid_Change(Object sender, DataGridPageChangedEventArgs e)
{
ItemsGrid.CurrentPageIndex = e.NewPageIndex;
ItemsGrid.DataSource = CreateDataSource();
ItemsGrid.DataBind();
}
void btnClick(Object sender, EventArgs e)
{
if(Request.Form["RadioName"] != null)
{
rd.Value = Request.Form["RadioName"].ToString();
Label1.Text = "您所选择的是:<font color=red>" + Request.Form["RadioName"].ToString() +"</font>";
}
}
</script>
<body>
<form runat="server" id="MM">
<input type="hidden" id="rd" runat="server">
<asp:DataGrid id="ItemsGrid" runat="server" BorderColor="black" BorderWidth="1" CellPadding="3"
AllowPaging="true" AutoGenerateColumns="false" OnPageIndexChanged="Grid_Change">
<HeaderStyle BackColor="#00aaaa"></HeaderStyle>
<PagerStyle Mode="NumericPages"></PagerStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<input type=radio name="RadioName" value='<%# DataBinder.Eval(Container.DataItem, "IntegerValue")%>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="数字列" DataField="IntegerValue" />
<asp:BoundColumn HeaderText="字符串列" DataField="StringValue" />
<asp:BoundColumn HeaderText="货币列" DataField="CurrencyValue" DataFormatString="{0:c}">
<ItemStyle HorizontalAlign="right"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
<br>
<asp:Button id="Btn" Text="看你选择的" OnClick="btnClick" runat="server" />
<asp:Label id="Label1" Text="" runat="server" />
</form>
</body>
</HTML>
打赏
举报
回复
赞
jedliu
2004-07-19
我要做的其中一个是删除该条记录,你的foreach(DataGridItem dagItem in dataGrid.Items)岂不没用了!
打赏
举报
回复
赞
jackyoung02
2004-07-19
使用模版列
其实就是一个阿
但是你选中不同的行,数据记录是不一样的阿
foreach(DataGridItem dagItem in dataGrid.Items)
{
//如果选中,则进行修改
if(((RadioButton)dataGrid.FindControl("RadioButtonID")).Checked == true)
{
}
}
打赏
举报
回复
赞
相关推荐
Flex4
DataGrid
中
嵌入
RadioButton
实现思路及代码
本节主要介绍了Flex4
DataGrid
中
嵌入
RadioButton
实现思路及代码,需要的朋友可以参考下
Flex4
DataGrid
中
如何嵌入
RadioButton
本文为大家介绍下Flex4
DataGrid
中
嵌入
RadioButton
的方法,下面有个不错的示例,感兴趣的朋友可以参考下
wpf
DataGrid
中
的
RadioButton
有一个需求,我们有很多条目,需要选择一个条目作为当前条目,这就需要用到单选,就需要
在
DataGrid
中
使用
RadioButton
, 我的数据
中
有一个字段为is_current, 为bool值,
在
RadioButton
中
,有一个IsChecked绑定是否选择...
datagrid
嵌入
radiobutton
datagrid
嵌入
radiobutton
在
easyui的
datagrid
中
如何显示图片?
在
easyui的
datagrid
中
如何显示图片? 解决方案:通过formatter实现,如下: {field:'spaceImgPath',title:'Space图片',width:100,align:'center', formatter: function(value,row,index){ //如下的写法太复杂...
WPF_MVVM
中
DataGrid
列
中
使用
ComBox绑定
WPF之MVVM
中
DataGrid
中
嵌入Combox,改变Combox可回传至绑定的实体
在
miniui
中
的
datagrid
行记录
中
使用
miniui按钮
miniUI
Datagrid
控件引入操作一般情况下可通过
在
在
页面
datagrid
控件
中
添加一个专门的操作列,并且通过ondrawcell 方法
在
操作列
中
添加相关操作,例如先如下建立
datagrid
<div id="
datagrid
" class=&...
在
jquery easyui
中
的
datagrid
中
添加searchbox!
研究了好久,终于成功
在
jquery easyui
中
的
datagrid
中
添加searchbox!
vb
中
datagrid
控件的详细
使用
方法
vb
中
datagrid
控件的详细
使用
方法,拿出来给大家看看!!!!是学习
datagrid
控件的好助手
WPF之
DataGrid
控件
使用
要实现对
DataGrid
单元格编辑,需先将
DataGrid
属性IsReadOnly设置为false,可以
在
DataGrid
定义
中
设置,这样是对全体单元格只读属性进行设置,也可以
在
列定义
中
设置,这样是对单个列字段进行设置。
DataGrid
单元格编辑...
EasyUI-
datagrid
中
使用
combobox设置默认值解决
JS
中
初始化
datagrid
,列
中
包含combobox,并为combobox设置默认值。 代码:只贴部分代码。 $("#id").
datagrid
.............. { field: "XXX", title: "XXX", width: "10%"...
DevExpress的GridControl
中
自定义列
中
使用
RadioButton
在
拉动滚动条后数据丢失的解决方法
在
DevExpress
中
使用
GridControl,其
中
有一列需要
使用
RadioButton
,有两个问题,一是
RadioButton
的数据绑定问题,详见上一篇文章,二是
在
选
中
RadioButton
后,如果滚动滚动条,选
中
状态就会丢失,原因
在
于整个...
RadioButton
Embed In The
DataGrid
Of Flex
利用FLEX,
在
DataGrid
中
嵌入
RadioButton
。
在
easyui
DataGrid
中
使用
linkbutton
如果 直接
在
field 的 formatter
中
直接 return 一个linkbutton 按钮,则无法显示图标,只有普通的 a 标签,无法加载样式,因为easyui 只
在
页面装载时渲染标签,因此
在
使用
formatter格式化列数据后,动态添加的...
flex
中
DataGrid
(表格)的
使用
这里我主要讲下
DataGrid
如下的几用法
DataGrid
绑定数据
DataGrid
动态添加列
DataGrid
里面添加自定义元素 1. Flex里面
DataGrid
绑定数据如下: xmlns:s="library:
easyui
datagrid
列
中
使用
tooltip
要实现这样一个效果:数据加载到
DATAGRID
中
,鼠标移至某一列时,会弹出tooltip提示框。
easyui
中
datagrid
如何
使用
formatter显示子对象的属性
如图 不是用formatter则显示的是来个[object object] 但是前台已经传过来值有俩种方法来
使用
第一种是
在
js里面直接利用formatter来进行获取$(function() { $("#tt") .
datagrid
( { ...
DataGrid
里面的
RadioButton
实现单选的处理
使用
Html控件和一个隐藏的textbox传值到后台。 onlick="SetValue(this.value);">function setvalue(Id){value txtbox = document.getElementById();txtbox.value = Id;}
C# WPF
DataGrid
使用
,包括隔行多选
C# WPF
DataGrid
使用
,包括隔行多选xamlcs xaml <ScrollViewer VerticalAlignment="Stretch" x:Name="scrollviewer" VerticalScrollBarVisibility="Hidden" ...
多种方式解决EasyUI—
DataGrid
中
DateTime的格式化问题
son序列化完成以后,
在
页面的easyui
datagrid
中
显示的时候出现了问题,不能正常显示,而是显示一列乱七八糟的 东西,见下图 上传图片 很明显这个格式的显示不是我们想要的结果,我们习惯的时间显示的方式
发帖
C#
加入
微信扫一扫
点击复制链接
10.7w+
社区成员
64.2w+
社区内容
.NET技术 C#
社区管理员
申请成为版主
帖子事件
创建了帖子
2004-07-19 10:25
社区公告
让您成为最强悍的C#开发者