当前位置: 首页 > news >正文

邯郸网站建设纵横在互联网上建设网站可选择的方案有

邯郸网站建设纵横,在互联网上建设网站可选择的方案有,企业网站优化案例,电子商务作业做网站最近一直在忙于工作项目的事,因此也许久未更新。这次更新一篇,在项目中遇见的一个奇特需求的解决方法。 在项目中,遇见一个需求,老板需要在表格中,加入单选框。 需求模板:需求如图中的工艺做法判定和质量判…

        最近一直在忙于工作项目的事,因此也许久未更新。这次更新一篇,在项目中遇见的一个奇特需求的解决方法。

        在项目中,遇见一个需求,老板需要在表格中,加入单选框。

需求模板:需求如图中的工艺做法判定和质量判定。

        在这个项目中,表格,我们使用的是asp:GridView。单选框我准备使用asp:RadioButtonList。

        需要在GridView中自定义列,则需要使用自定义模板asp:TemplateField。

具体前台代码

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"ForeColor="#333333" GridLines="None"OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"OnRowUpdating="GridView1_RowUpdating"OnRowCancelingEdit="GridView1_RowCancelingEdit" CssClass="DataGridBorder"Width="900" Font-Size="16px" OnRowDataBound="GridView1_RowDataBound"><FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /><Columns><asp:BoundField DataField="Serial" HeaderText="序号" ReadOnly="true" HeaderStyle-Width="60" /><asp:BoundField DataField="Position" HeaderText="部位名称" ReadOnly="true" HeaderStyle-Width="100" /><asp:TemplateField HeaderText="工艺做法判定"><ItemTemplate><asp:RadioButtonListID="CraftWay" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow"><asp:ListItem Value="正确">正确</asp:ListItem><asp:ListItem Value="错误">错误</asp:ListItem></asp:RadioButtonList></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="质量判定"><ItemTemplate><asp:RadioButtonListID="Quality" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow"><asp:ListItem Value="合格">合格</asp:ListItem><asp:ListItem Value="不合格">不合格</asp:ListItem></asp:RadioButtonList></ItemTemplate></asp:TemplateField><asp:BoundField DataField="DetailNote" HeaderText="备注说明" HeaderStyle-Width="150" /><asp:CommandField HeaderText="选择" ShowSelectButton="True" /><asp:CommandField HeaderText="编辑" ShowEditButton="True" /><asp:CommandField HeaderText="删除" ShowDeleteButton="True" /></Columns><RowStyle CssClass="DataGridHeadr" /><SelectedRowStyle CssClass="GridViewSelectedRowStyle" /><PagerStyle CssClass="DataGridPager" /><HeaderStyle CssClass="GridViewHeaderStyle" />
</asp:GridView>

后台获取表格单选框信息代码

for (int i = 0; i < GridView1.Rows.Count; i++)
{DataRow newRow = dtInfo.NewRow();//部位string position = GridView1.DataKeys[i]["Position"].ToString();// position == "&nbsp;":防止为空时,获取的是:&nbsp:if (position == "&nbsp;") position = "";newRow["Position"] = position;//标识string serial = GridView1.Rows[i].Cells[0].Text;if (serial == "&nbsp;") serial = "";newRow["Serial"] = serial;// 工艺做法判定string craftWay = ((RadioButtonList)(GridView1.Rows[i].FindControl("CraftWay"))).Text;newRow["CraftWay"] = craftWay;// 质量判定string quality = ((RadioButtonList)(GridView1.Rows[i].FindControl("Quality"))).Text;newRow["Quality"] = quality;//备注说明string detailNote = GridView1.Rows[i].Cells[4].Text;if (detailNote == "&nbsp;") detailNote = "";newRow["DetailNote"] = detailNote;dtInfo.Rows.Add(newRow);
}

使用 RadioButtonList)(GridView1.Rows[i].FindControl("单选框ID") 可以获取到该行的单选框,再用 .Text 可以获取到选择的选项数据。用循环读取,可以获取到整个 GridView 表格信息。

后台绑定数据到前台代码

// 副表单选框处理
protected void TableRadlSelect()
{for (int i = 0; i < dtInfo.Rows.Count; i++){// 根据数据绑定,如果为空则清空单选框的选择,不为空则绑定选项if (dtInfo.Rows[i]["CraftWay"].ToString() == "" || dtInfo.Rows[i]["CraftWay"] == null){// 清空选项选择((RadioButtonList)(GridView1.Rows[i].FindControl("CraftWay"))).Items[0].Selected = false;((RadioButtonList)(GridView1.Rows[i].FindControl("CraftWay"))).Items[1].Selected = false;}else{// 绑定选项((RadioButtonList)(GridView1.Rows[i].FindControl("CraftWay"))).Text = dtInfo.Rows[i]["CraftWay"].ToString();}if (dtInfo.Rows[i]["Quality"].ToString() == "" || dtInfo.Rows[i]["Quality"] == null){((RadioButtonList)(GridView1.Rows[i].FindControl("Quality"))).Items[0].Selected = false;((RadioButtonList)(GridView1.Rows[i].FindControl("Quality"))).Items[1].Selected = false;}else{((RadioButtonList)(GridView1.Rows[i].FindControl("Quality"))).Text = dtInfo.Rows[i]["Quality"].ToString();}}
}

        对于后台绑定数据到前台展示,我创建了一个方法,每次需要使用的时候,调用这个方法进行绑定。

http://www.sczhlp.com/news/63464/

相关文章:

  • 做教育培训网站手机 电脑 同步 wordpress
  • 设计logo的网址网站title优化
  • 中小学 网站建设 通知网站如何做三端适配
  • wordpress 导入网站模板做app和做网站哪个容易
  • 网站模版购买网络游戏推广员
  • 成都维尼网络 网站建设手表哪个网站最好
  • 运城微信网站建设新乐做网站优化
  • 博客网站如何设计asp手机网站开发教程
  • 谷歌有做网站建设广州外贸营销网站建设公司
  • 沧县做网站软件产品设计方案
  • 5年网站seo优化公司怎么做网站不用备案
  • 网站建设+临沂企业做网站需要注意事项
  • 政务服务 网站 建设方案杭州高端网站建设公司哪家好
  • 网站ftp的所有权归谁新网站怎样做好外链
  • 怎么在别人网站做跳转商派商城网站建设
  • 企业网站开发公司有哪些php网站案例
  • 茶叶手机网站如何查询网站的建设商
  • 专业沈阳网站制作ppt设计报价
  • 苏州高端网站设计机构深圳网站制作需要多少钱
  • 网站设计的基本知识织梦网站入侵
  • ui交互设计作品wordpress数据库优化
  • 九江网站设计wordpress插件语言包
  • ps网站头部图片住房城乡住房和城乡建设部网站首页
  • sqlite做网站洛阳做网站哪家好
  • 深圳 商城 网站建设义乌网站网站建设
  • 深圳市文刀网站建设免费推广网站推荐
  • 商务网站的建设阶段包括装修室内设计培训学校
  • 响应式网站用什么开发的网络设计案例题
  • 网站站群建设进度wordpress 中介
  • 网站平台建设心得iis怎么添加网站