GridView进入Edit模式,编辑列动态绑定DropDown List方便客户选择,但当里面的Item过长,不免令界面不美观

正确做法:

<asp:TemplateField HeaderText="test1" SortExpression="Lv1" >
                <ItemTemplate>
                    <%# Eval("Lv1")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:dropdownlist ID="test1"  width="148px" runat="server" Text='<%# Bind("Lv1") %>'    DataSource = "<%#getInitDT(0)%>" DataTextField ="Info"  DataValueField ="Code">
                     </asp:dropdownlist>
                </EditItemTemplate>
                <ItemStyle Width="150px" />
</asp:TemplateField>

做法1:其它列宽也变化,而且DropDown List显示不正常

 gv_Test.Style.Add("table-layout", "fixed")

做法2:IE9正常,IE8有问题,Header宽度没变

<asp:TemplateField HeaderText="test2" SortExpression="Lv2">
                <ItemTemplate>
                    <%# Eval("Lv2")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:dropdownlist ID="test2"  runat="server" style="max-width 100px !important; width: auto !important; width:100px;" Text='<%# Bind("Lv2") %>' DataSource="<%#getInitDT(1)%>" DataTextField ="Info"  DataValueField ="Code">
                     </asp:dropdownlist>
                </EditItemTemplate>
            </asp:TemplateField>

无效做法3:

<EditRowStyle Width="150" />
无效做法4:
<RowStyle BackColor="#E7E7FF" ForeColor="DarkSlateBlue"  HorizontalAlign ="left" Wrap ="false" Width ="150px" />

GridView修改含有DropDownList控件列的宽度的更多相关文章

  1. DropDownList 控件不能触发SelectedIndexChanged 事件

    相信DropDownList 控件不能触发SelectedIndexChanged 事件已经不是什么新鲜事情了,原因也无外乎以下几种: 1.DropDownList 控件的属性 AutoPostBac ...

  2. 三级联动---DropDownList控件

    AutoPostBack属性:意思是自动回传,也就是说此控件值更改后是否和服务器进行交互比如Dropdownlist控件,若设置为True,则你更换下拉列表值时会刷新页面(如果是网页的话),设置为fl ...

  3. DropDownList 控件

    今天打算学习下dropdownlist控件的取值,当你通过数据库控件或dataset绑定值后,但又希望显示指定的值,这可不是简单的值绑定就OK,上网搜了一些资料,想彻底了解哈,后面发现其中有这么大的奥 ...

  4. 在FooterTemplate内显示DropDownList控件

    如果想在Gridview控件FooterTemplate内显示DropDownList控件供用户添加数据时所应用.有两种方法可以实现,一种是在GridView控件的OnRowDataBound事件中写 ...

  5. Dev控件GridView单元格绑定控件

    Dev控件GridView单元格绑定控件 //文本按钮 RepositoryItemButtonEdit btnFields = new RepositoryItemButtonEdit();//创建 ...

  6. DropDownList控件

    1.DropDownList控件 <asp:DropDownList runat="server" ID="DropDownList1" AutoPost ...

  7. c#中DropDownList控件绑定枚举数据

    c# asp.net 中DropDownList控件绑定枚举数据 1.枚举(enum)代码: private enum heros { 德玛 = , 皇子 = , 大头 = , 剑圣 = , } 如果 ...

  8. 修改Delphi工具控件的默认字体

    修改Delphi工具控件的默认字体: 注册表: Delphi 6:    HKEY_CURRENT_USER\Software\Borland\Delphi\6.0Delphi 7:    HKEY_ ...

  9. DropDownList控件学习

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

随机推荐

  1. 【Qt】Qt5.12连接MySQl5.7(亲自测试成功)

    目录 00. 目录 01. Qt5.12连接MySQL5.7测试代码 02. Qt5.12连接MySQL5.7问题描述 03. 解决办法 04. 结果测试 05. 打赏 00. 目录 01. Qt5. ...

  2. 在uboot里面添加环境变量使用run来执行

    在uboot里面添加环境变量使用run来执行 本文链接:https://blog.csdn.net/u010979030/article/details/41038259 Author:杨正  Dat ...

  3. Python Unittest进行接口测试的简单示例

    今年肯定是要把Python学到一定程度的,否则感觉自己混不下去了,那就开始半挣扎的咸鱼生活吧. ---------------------------------------------------- ...

  4. [v]Linux下安装Git

    Ubuntu12.04中默认没有安装Git.需要自行安装. 1. 安装Git 1.1 Ubuntu12.04下 可以使用apt-get方式安装,也可以下载源代码安装[1],我们这里使用apt-git安 ...

  5. SaltStack实现动态文件分发,支持脚本换行,中文乱码

    场景:将动态脚本分发到各个机器的指定目录下 说明:使用SaltStack的 file.managed file.managed 里面可以定义内容的几种方式 - source: - contents: ...

  6. python练习:异常

    异常习题: 一 编写with操作类Fileinfo(),定义__enter__和__exit__方法.完成功能: 1.1 在__enter__方法里打开Fileinfo(filename),并且返回f ...

  7. ASP.NET Core 2.1 中的 HttpClientFactory (Part 1) HttpClientFactory介绍

    原文:https://www.stevejgordon.co.uk/introduction-to-httpclientfactory-aspnetcore  发表于:2018年1月 ASP.NET ...

  8. java判定数据(对象)类型

    1.说明一 int 是关键字,Integer是包装类,Number是所有数字了的基类(父类).所以,Number是Integer的基础,Integer是int的基础,也称Integer是int的原型类 ...

  9. {T4模板}C# Net MVC+SqlServer=T4模板生成实体类并操作数据(DbHelper+DBManage)

    1.ConnectionString,数据库链接 Web.config <configuration> <connectionStrings> <!-- 数据库 SQL ...

  10. 定制ubuntu镜像

    使用ubuntu server 18.04 lts版镜像 作为源镜像定制目标镜像, 工具cubic, 定制目标镜像, 使得一些服务装机后即可使用,例如redis, mysql, monggodb ,s ...