附上案例

<asp:GridView ID="gvApprove" runat="server" Width ="100%" AutoGenerateColumns="False" AllowPaging="True" PagerSettings-Visible="false" PageSize="20"CssClass="gtab" UseAccessibleHeader="true" OnRowDataBound="gv_AccountInfo_RowDataBound"><Columns><asp:TemplateField HeaderText="評估選擇"><ItemTemplate><asp:RadioButtonList runat="server" ID="cheRadio" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow" Enabled="false"><asp:ListItem Value="0">是</asp:ListItem><asp:ListItem Value="1">否</asp:ListItem></asp:RadioButtonList> <asp:TextBox ID="txt_CheRadio" runat="server" Style="display: none" Text='<%#DataBinder.Eval(Container,"DataItem.Name") %>'></asp:TextBox></ItemTemplate></asp:TemplateField></Columns></asp:GridView>

RadioButtonList :Text=‘<%#DataBinder.Eval(Container,“DataItem.Name”) %>’
Label:Text=‘<%#DataBinder.Eval(Container, “DataItem.ASSESS_CONTENT”)%>’
OnRowDataBound=“gv_AccountInfo_RowDataBound”

    //單選框protected void gv_AccountInfo_RowDataBound(object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow){TextBox txt_CheRadio = (TextBox)e.Row.FindControl("txt_CheRadio");RadioButtonList rbl_LastManageResult = (RadioButtonList)e.Row.FindControl("sign_mode");rbl_LastManageResult.SelectedValue = txt_CheRadio.Text.Trim();}}

方法二更简单
直接一个for循环遍历赋值到选择

DataTable dtComments = obj.Get_Form_Comments(strFormCode);
gvComments.DataSource = dtComments;
gvComments.DataBind();
for (int i = 0; i < dtComments.Rows.Count; i++)
{RadioButtonList chk_Result = (RadioButtonList)gvComments.Rows[i].FindControl("chk_Result");chk_Result.SelectedValue = dtComments.Rows[i]["SIGN_RESULT"].ToString();
}

C# GridView綁定RadioButtonList相关推荐

  1. GridView 梆定一个实体类

    1.先创建一个名为Customer的实体类,代码如下: using System; using System.Collections.Generic; using System.Linq; using ...

  2. 讓combobox也綁定數據表

    是否已不滿足Combobox的一成不變的沒有表頭的datasource,是否想打造一個有表頭的呢?follow me!最終效果圖如下﹕ 為了實現如上效果圖﹐讓我們一步一步來實現﹕ Step1: 打開V ...

  3. CPU亲和性的使用与机制--含Xen中VCPU和PCPU的綁定方法

    CPU的亲和性, 就是进程要在指定的 CPU 上尽量长时间地运行而不被迁移到其他处理器,亲和性是从affinity翻译过来的,应该有点不准确,给人的感觉是亲和性就是有倾向的意思,而实际上是倒向的意思, ...

  4. 【boundfield】GridView中BoundField与TemplateField的区别_boundfield

    GridView中BoundField与TemplateField的区别? 都不知道用哪个好? TemplateField灵活呗. 有时候必须要用到TemplateField,比如你想通过GridVi ...

  5. VS2005中GridView簡單應用

    GridView是VS2005中對VS2003的DataGrid的增強替代控件 下面展示一下它的基本常見應用 效果圖如下: [查詢]按鈕:查詢數據庫 ,顯示信息Table 並 綁定GridView / ...

  6. android gridview添加标题,android gridview布局添加多個title

    在項目中要求實現在gridview的布局效果上添加title,並且是多個在不同地方的title,每個title占據一整行,下面分享一下如何實現 先上效果圖: 1.首先添加title到list集合中:L ...

  7. GridView中BoundField与TemplateField的区别

    .NET学习日记 2009-09-15 16:29:30 阅读299 评论0   字号:大中小 订阅 BoundField只能实现一个固定的显示格式,而TemplateField可以实现任意你想达到的 ...

  8. 浅谈Android四大组件之Service

    一:Service简介 Android开发中,当需要创建在后台运行的程序的时候,就要使用到Service. 1:Service(服务)是一个没有用户界面的在后台运行执行耗时操作的应用组件.其他应用组件 ...

  9. oracle9i的全局变量,Oracle9i, 10g 如何抓取绑定变量的值

    1)10046論斷事件 設置方法: 全局設置:初始參數文件中設置event="10046 trace name context forever,level 12" 本地sessio ...

最新文章

  1. Linux 用户行为日志记录
  2. [DB那些事]数据库加密
  3. Git clone时出现Please make sure you have the correct access rights and the repository exists.问题已解决。
  4. POJ2406 KMP前缀周期
  5. 微信扫一扫识物的技术揭秘:抠图与检索
  6. 关于win32与win64的兼容性问题
  7. sql server 以10分钟分组 统计人数
  8. jquery 设置style:display 其实很方便的哦
  9. nginx 启动命令_Nginx实战001:Window中配置使用Nginx入门
  10. YBT高效进阶3.4.2 洛谷P2341 POJ2186受欢迎的牛Popular Cows
  11. 360校招笔试算法题
  12. 基于微信小程序的大学生心理健康测试设计与实现 .docx
  13. android 定位工具类,高德地图定位工具类
  14. 跨境电商B2B是什么?跨境电商B2B模式如何定义?
  15. unwallet白皮书解读
  16. iOS动画 Masonry约束弹框动画animateWithDuration:
  17. 深度学习,提高前列腺癌诊断正确率
  18. DEBUG系列一:Dumpdebug_SAP刘梦_新浪博客
  19. 手机测试android程序下载,测手速下载_测手速手机版下载「安卓版」-太平洋下载中心...
  20. 【PKI技术】第一弹 — 什么是PKI?

热门文章

  1. css解决 多张图片如何统一大小 且没拉伸问题
  2. 网络工程师----成长之路
  3. memtester --转载
  4. python如何限制字符串长度_python如何修改字符串长度
  5. 台式电脑计算机硬盘清理,小编教您台式电脑如何清理灰尘
  6. Java 不赚钱,要转 Go 吗?
  7. 数据库与MPP数仓(十九):高效SQL
  8. 【JavaWeb】一文学会JPA
  9. java鸡兔同笼用循环_Java使用for循环解决经典的鸡兔同笼问题示例
  10. leetcode java 大厂基础面试题附答案(二)