Gridview,RadioButtonList
来源:互联网 发布:vscode新建c工程 编辑:程序博客网 时间:2024/06/02 07:30
1.GridView
在aspx页面加gridview控件
<asp:GridView ID="grid1" runat="server" OnRowDataBound="grid1_RowDataBound" HeaderStyle-CssClass="tdbackcolor" Font-Size="14px" CellPadding="5"> <HeaderStyle CssClass="tdbackcolor" BackColor="Gainsboro"></HeaderStyle> <FooterStyle BackColor="Gainsboro" Font-Size="14px" /> </asp:GridView>后台代码
grid1.Columns.Clear(); BoundField col = new BoundField(); col.DataField = "name"; col.HeaderText = "姓名"; col.Visible = true; grid1.Columns.Add(col); BoundField col1 = new BoundField(); col1.DataField = "age"; col1.HeaderText = "年龄"; col1.Visible = true; grid1.Columns.Add(col1); BoundField col2 = new BoundField(); col2.DataField = "school"; col2.HeaderText = "学校"; col2.Visible = true; grid1.Columns.Add(col2); //添加数据源 DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("name", typeof(string))); dt.Columns.Add(new DataColumn("age", typeof(decimal))); dt.Columns.Add(new DataColumn("school", typeof(string))); dt.Rows.Add("张三", 16, "一中"); dt.Rows.Add("李四", 13, "二中"); dt.Rows.Add("王五", 14, "九中"); dt.Rows.Add("陈留", 17, "六中"); dt.Rows.Add("吴七", 18, "七中"); //将gridview的数据源绑定为dt,这样的话,gridview自定义的字段名会和表中字段名匹配,相同的则显示该列的数据 grid1.AutoGenerateColumns = false; this.grid1.DataSource = dt; this.grid1.DataBind();效果:
2.RadioButtonList
apsx页面上:
<asp:RadioButtonList RepeatDirection="Horizontal" runat="server" ID="cqcAnalysisType" RepeatLayout="Table" AutoPostBack="True"> </asp:RadioButtonList>
后台添加项:
this.cqcAnalysisType.Items.Add(new ListItem("吃饭", "eat")); this.cqcAnalysisType.Items.Add(new ListItem("睡觉", "sleep")); this.cqcAnalysisType.Items.Add(new ListItem("唱歌", "sing"));
效果图:
0 0
- Gridview,RadioButtonList
- RadioButtonList
- RadioButtonList
- RadioButtonList
- GridView模版列中根据数据动态添加RadioButtonList项
- GridView中radiobuttonlist回传时保存已选择的项
- jquery 获取 GridView 或 Repeater 里边的 RadioButtonList 选中值
- ASP.NET:GridView翻页时保存模板列内的RadioButtonList选择状态
- GridView在打开时从数据库中选出radiobuttonlist的值
- 自定义RadioButtonList
- RadioButtonList专题
- RadioButtonList控件
- RadioButtonList控件
- RadioButtonList用法
- RadioButtonList简述
- radiobuttonlist问题
- 绑定RadioButtonList
- RadioButtonList样式
- 第十六周项目4-为动态数组扩容
- 使用代码为textview设置drawableLeft
- 年龄从大到小输出通讯录信息(OJ上通过,但是DEVC++上一直乱码和要多输几位)
- oracle ORA-01017 用户无法通过登录
- 使用dll注入技术给windows任务管理器增加功能
- Gridview,RadioButtonList
- 3、看门狗实验
- 修改linux内核kernel开机logo(小企鹅)
- EBS功能在线帮助文档系统
- MongoDB的$where查询
- R语言 tm包的使用
- QTcpServer如何监听两个不同的端口
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法
- 【LeetCode】Count and Say