gridview动态绑定dropdownlist
发布日期:2021-07-17 20:20:31 浏览次数:10 分类:技术文章

本文共 876 字,大约阅读时间需要 2 分钟。

  1. 一、ASPX
  2. <asp:GridView ID="wztb1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
  3.                                 CellPadding="4" ForeColor="#333333" GridLines="None" Width="1800px" 
  4.                                 onrowcreated="wztb1_RowCreated">
  5.    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" />
  6.          <Columns>
  7.           <asp:TemplateField HeaderText="价格类型">
  8.               <ItemTemplate>
  9.                    <asp:DropDownList ID="DDL_PriceType" runat="server">
  10.                    </asp:DropDownList>
  11.               </ItemTemplate>
  12.            </asp:TemplateField>
  13.         </Columns>
  14.  </asp:GridView>
  15. 二、ASPX.CS
  16. //价格类型类
  17.         IPriceType pt = FPriceType.CreatPriceType();
  18.         protected void wztb1_RowCreated(object sender, GridViewRowEventArgs e)
  19.         {
  20.             DropDownList ddl = (DropDownList)e.Row.FindControl("DDL_PriceType");
  21.             //表头表尾创建时dll==null
  22.             if (ddl != null)
  23.             {
  24.                 ddl.DataSource = pt.SelectPriceType();
  25.                 ddl.DataTextField = "tb_PT_Name";
  26.                 ddl.DataValueField = "tb_PT_Name";
  27.                 ddl.DataBind();
  28.             }
  29.         }
  30. 三、欢迎讨论:ikmb@163.com QQ:154179812

转载地址:https://blog.csdn.net/ikmb/article/details/3528692 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:用__doPostBack()方法调用后台方法的方式中,页面没有__doPostBack()函数的解决
下一篇:元素 float:right 后右对齐换行原因

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月11日 05时04分09秒