关于asp.net中下拉列表的问题 [英] Question about dropdownlist in asp.net

查看:72
本文介绍了关于asp.net中下拉列表的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了这个下拉列表

  asp:DropDownList ID =Course_Namerunat =serverHeight =25pxclass =div< br /> 
width =150pxAutoPostBack =true< br />
style =margin-left:45pxontextchanged =Course_Name_TextChanged< br />
< ; br />
< asp:ListItem Selected =True> -Select-< / asp:ListItem>< br />
< / asp:DropDownList> < br />











这个下拉列表位于我项目的教师模块中。下拉列表位于view_student_assignments页面..当教师登录并访问view_student_assignments页面然后在页面加载所有分配给这位老师的课程来在下拉列表中...像课程名称是MM,CS,DM,ICT。分配给该教师的课程分为MM,CS,DM,ICT系列。当教师选择课程MM时,没有任何分配意味着此时没有发生文字转换,当教师选择CS课程然后ontextchanged事件发生并且分配显示在gridview中,当老师再次选择MM课程然后这次ontextchanged事件发生并且所有作业显示...我想当view_student_assignments页面加载然后在dropdownliast拳头来 - 选择课程 - 。喜欢这个系列(-Choose-,MM,CS, DM,ICT)。



如何可能???

解决方案

绑定<$ c $后c> DropDownList ,你应该绑定那个默认项目,如...

 Course_Name.Items.Insert( 0    - 选择 - ); 


I have design this dropdownlist

asp:DropDownList ID="Course_Name" runat="server" Height="25px" class="div"<br />
        width="150px"  AutoPostBack="true"<br />
        style="margin-left: 45px" ontextchanged="Course_Name_TextChanged" <br />
<br />
 <asp:ListItem Selected="True" >-Select- </asp:ListItem><br />
    </asp:DropDownList> <br />
  






This dropdownlist is in teacher module in my project.The dropdownload list is in view_student_assignments page ..When teacher login and visit view_student_assignments page then at page load all the courses which are assign to this teacher come in dropdownlist...like name of courses are MM,CS,DM,ICT. courses which are assign to this teacher come in this series MM,CS,DM,ICT.When teacher Choose course MM then no assignment appear mean at this time no textchangedevent occur ,when teacher choose CS course then ontextchanged event occur and assignments display in gridview,after it when teacher again choose MM course then this time ontextchanged event occur and all assignments display...I want when view_student_assignments page load then in dropdownliast fist come -Choose Course - .Like This Series (-Choose-,MM,CS,DM,ICT).

How possible???

解决方案

After binding the DropDownList, you should bind that default item like...

Course_Name.Items.Insert(0, "-Choose-");


这篇关于关于asp.net中下拉列表的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆