zoukankan      html  css  js  c++  java
  • GridView中编辑状态下实现DropDownList默认值(原创)

    之前看到很多网友包括孟子e章兄的默认值方法,觉得比较麻烦,自己写了个简单方法,欢迎大家指证!

    前台:

    <asp:TemplateField HeaderText="资质">
                            <ItemTemplate>
                                <asp:Label ID="lblAptitude" runat="server" Text='<%#Eval("Aptitude") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:Label ID="lbl2" runat="server" Text='<%#Eval("Aptitude") %>' style="display:none;"></asp:Label>
                                <asp:DropDownList ID="ddlAptitude" runat="server">
                                    <asp:ListItem Value="合格" Text="合格"></asp:ListItem>
                                    <asp:ListItem Value="储备" Text="储备"></asp:ListItem>
                                    <asp:ListItem Value="潜在" Text="潜在"></asp:ListItem>
                                    <asp:ListItem Value="不合格" Text="不合格"></asp:ListItem>
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateField>

    后台:

     protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
                    if (e.Row.RowIndex == gvList.EditIndex)
                    {
                        //编辑时下拉菜单默认值
                        ddlAptitude.Text = ((Label)e.Row.FindControl("lbl2")).Text;
                     } 

         }

    欢迎大家发表意见,xiexie

  • 相关阅读:
    几种加密算法的java实现包括MD5、RSA、SHA256
    js 向form表单中插入数据
    HTTP的长短连接、长短轮询的区别(转载)
    try catch finally 关闭流标准的写法
    从黑格尔的正反合理论看人生的三个阶段
    《人人都是产品经理》读书笔记
    什么是PRD、MRD与BRD
    关于B/S系统中文件上传的大小限制怎么做
    如何向外行解释产品经理频繁更改需求为什么会令程序员烦恼?
    web页面开发笔记(不断更新)
  • 原文地址:https://www.cnblogs.com/Golf9527/p/1623416.html
Copyright © 2011-2022 走看看