首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

初学都有关问题?DropDownList怎么默认值?

2011-12-12 
初学都问题?DropDownList如何默认值??在GridView里加入DropDownList,数据从库中邦定,编辑时如何设置默认值

初学都问题?DropDownList如何默认值??
在GridView里加入DropDownList,数据从库中邦定,编辑时如何设置默认值??

下面是我在后台的设置,但不对啊ropDownList不能默认!!!还有顺便请教下如果是删除,如果删除为管理员自己行,那么GridView中的删除按扭不可用如何设置??
  protected   void   GridView1_RowDataBound(object   sender,   GridViewRowEventArgs   e)
        {

                Label   user   =   (Label)e.Row.FindControl( "Name ");
                if   (user.Text   ==   Request.Cookies[ "name "].Value)
                {
                        LinkButton   Del   =   (LinkButton)e.Row.FindControl( "LinkButton2 ");
                        Del.Enabled   =   false;
                }
                        DropDownList   RoleId   =   (DropDownList)e.Row.FindControl( "RoleId ");
                        OleDbDataReader   DataReader   =   DataOption.GetDataRead( "select   Rid   from   Role   where   Rname= ' "   +   Request.Cookies[ "Rname "].Value   +   " ' ");
                        RoleId.SelectedValue   =   Request.Cookies[ "Rname "].Value;
                        //RoleId.SelectedIndex   =   Convert.ToInt32(DataReader[ "Rid "]);
           
        }

前台   DropDownList
                      <asp:TemplateField   HeaderText= "角色 ">
                                <EditItemTemplate>
                                        <asp:DropDownList   ID= "RoleId "   runat= "server "   DataSource= " <%#RoleDownList()%> "  
DataTextField= "Rname "   DataValueField   =   "Rid ">

                                        </asp:DropDownList>
                                </EditItemTemplate>
                                <ItemTemplate>
                                        <asp:Label   ID= "lblRoleId "   runat= "server "   Text= ' <%#   Eval( "Rname ")   %> '> </asp:Label>
                                </ItemTemplate>
                        </asp:TemplateField>



[解决办法]
<asp:DropDownList selectedvalue= ' <%#eval( " ") %> ' ID= "DropDownList1 " runat= "server ">

你的这个做法应该没有错啊.
LinkButton Del = (LinkButton)e.Row.FindControl( "LinkButton2 ");
Del.Enabled = false;
[解决办法]
是不是dropdownlist的id搞错了?

热点排行