下拉列表数据源

编程入门 行业动态 更新时间:2024-10-25 06:22:14
本文介绍了下拉列表数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我正在使用部门的下拉列表 我的部门包含 1 2 3 部门 当我使用数据源时,它仅显示1 2 3. 我想显示选择一个部门值"作为第一个,如何实现. 我的代码是:

Hi All, I am using drop down list for department my dept contains 1 2 3 departments When i am using data source it is showing only 1 2 3 . I want to display "select a dept value" as first one, how can I achieve that. my code is:

<asp:DropDownList ID="ddlDept" runat="server" DataSourceID="SqlDataSource1" DataTextField="DeptID" DataValueField="DeptID" Font-Underline="False"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EmployeeDetailsConnectionString4 %>" SelectCommand="SELECT DISTINCT [DeptID] FROM [Department]"> </asp:SqlDataSource>

请帮帮我. 在此先感谢.

please help me. Thanks in Advance.

推荐答案

ConnectionStrings:EmployeeDetailsConnectionString4 %> " SelectCommand =" 从[部门]中选择[DeptID]" > ; < /asp:SqlDataSource > ConnectionStrings:EmployeeDetailsConnectionString4 %>" SelectCommand="SELECT DISTINCT [DeptID] FROM [Department]"> </asp:SqlDataSource>

请帮帮我. 预先感谢.

please help me. Thanks in Advance.

尝试一下... Try this ... ddlDept.Items.Insert(0, new ListItem("--select a dept value--", "-1"));

<asp:DropDownList ID="ddlDept" runat="server" DataSourceID="SqlDataSource1" DataTextField="departments" DataValueField="DeptID" Font-Underline="False"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%

更多推荐

下拉列表数据源

本文发布于:2023-08-05 21:34:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1308190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据源   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!