全国统一热线:
028-86758058
18980748058
购买流程
付款方式
常见问题
在线提问
续租服务
购物车(
0
件)
用户名:
密 码:
记住
首 页
HOME
域名注册
DOMAIN
虚拟主机
WEB HOST
成品网站超市
AUTO Site
VPS主机
VPS SERVER
云 主 机
CLOUD HOST
租用托管
SERVER
海外主机
HK HOST
代理专区
AGENT
客服中心
SERVICE
站长教程
SERVICE
欢迎光临西部数据云计算中心,我们将竭诚为您提供最优质的服务!
中文域名
域名转入
域名转出
DNS管理
动态域名
获取域名证书
域名停放
域名过户
集群主机
双线主机
基本主机
港台主机
论坛主机
Linux主机
Vip合租主机
超G型主机
ASP.net主机
Java主机
智能建站主机
网店主机
美国主机
数据库
成品网站超市
智能建站主机
集群VPS主机
国内VPS主机
香港VPS主机
美国VPS主机
云主机介绍
云主机购买
服务器租用
主机托管
常见问题
香港主机
港台主机
美国主机
国内免备案
步骤流程
代理级别
代理合同
代理模式
代理优势
在线申请
产品列表
常见问题
代理商分布图
常见问题
有问必答
跟踪提问
购买流程
产品价格
付款方式
常用软件
网站备案
续租服务
汇款确认
相关文档
联系我们
域名资讯
主机资讯
行业动态
网页制作
php教程
mysql教程
域名资讯
云计算资讯
网络编程
您当前的位置:
首页
>
网络编程
>
Net教程
gridview中实现radiobutton的单选示例
时间:2015-01-29 来源:互联网 作者:佚名
c# 代码
复制代码
代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
RadioButton rb = (RadioButton)e.Row.FindControl("rbtSelect");
if (rb != null)
rb.Attributes.Add("onclick", "onClientClick('" + rb.ClientID + "','" + e.Row.RowIndex + "')"); //把选中行的RowIndex也传过去,提交后在
服务器
端取值时用
}
}
javascript代码
复制代码
代码如下:
<script type="text/javascript">
function onClientClick(selectedId, rowIndex)
{
//用隐藏控件记录下选中的行号
var hidden = document.getElementById("Hidden1").value=rowIndex;
var inputs = document.getElementById("<%=GridView1.ClientID%>").getElementsByTagName("input");
for(var i=0; i <inputs.length; i++)
{
if(inputs[i].type=="radio")
{
if(inputs[i].id==selectedId)
inputs[i].checked = true;
else
inputs[i].checked = false;
}
}
}
</script>
hmtl代码:
复制代码
代码如下:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="648px" Font-Size="9pt" onrowcommand="GridView1_RowCommand"
DataKeyNames="id" onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton ID="rbtSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="文件名">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtDirName" CommandName="Change" CommandArgument='<%#Container.DataItemIndex %>'>
<%#Eval("AA") %>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="BB" HeaderText="字段1" />
<asp:BoundField DataField="CC" HeaderText="字段2" />
<asp:BoundField DataField="DD" HeaderText="字段3" />
<asp:BoundField DataField="EE" HeaderText="字段4" />
</Columns>
</asp:GridView>
<input id="Hidden1" type="hidden" runat="server"/>
来顶一下
返回首页
推荐资讯
.net mvc页面UI之Jquery博客日历控
一、效果图二、页面文件页面上需要添加<div id="cal"></di
Asp.net 自带报表的使用详解
1:新建報表所需的數據源DataSet.cs复制代码 代码如下:using
相关文章
asp.net使用jQuery获取RadioButtonList成员选中内容和
GridView使用CommandField删除列实现删除时提示确认框
GridView自定义删除操作的具体方法
ASP.NET服务器端控件RadioButtonList,DropDownList,
GridView中checkbox"全选/取消"完美兼容IE和Firefox
实例讲解动态加载gridview中的行及其样式
为GridView的行添加鼠标经过、点击事件的小例子
Asp.Net如何将多个RadioButton指定在一个组中
ASP.NET中的DataGridView绑定数据和选中行删除功能具体
asp.net gridview列宽固定的几种方法介绍
栏目更新
栏目热门
返回首页
关于我们
联系我们
付款方式
价格总览
资讯中心
友情链接
媒体关注
有问必答
投诉建议
网站备案
《中华人民共和国增值电信业务经营许可证》编号:川B2-20080058号
官方网址:
xibushuju.com
西部数据
Copyright © 2002~2015
天府快车
版权所有
电话总机:
028-86758058
(50线) 传真:
028-86758058