using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data; namespace WebApplication1
{
public partial class DropDownList控件 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindMonthList();
BindUserList();
} }
private void BindMonthList()
{
int[] monthList=new int[];
for (int i = ; i <= ; i++)
{
monthList[i] = i + ;
}
ddlMonthList.DataSource = monthList;
ddlMonthList.DataBind(); }
private void BindUserList()
{
SqlConnection conn = new SqlConnection(@"server=Rose-PC\SQLEXPRESS;Database=User;User Id=sa;password=");
SqlCommand command = new SqlCommand("Select ID,RealName from UserInfo", conn);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable data = new DataTable();
adapter.Fill(data); ddlUserList.DataTextField = "RealName";
ddlUserList.DataValueField = "ID";
ddlUserList.DataSource = data;
ddlUserList.DataBind(); } }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DropDownList控件.aspx.cs" Inherits="WebApplication1.DropDownList控件" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddlMonthList" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="ddlUserList" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>

DropDownList控件学习的更多相关文章

  1. DropDownList 控件

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

  2. Winform控件学习笔记【第二天】——常用控件

    背景:期末考试刚过就感冒了,嗓子火辣辣的,好难受.但是一想起要学习总结就打起精神来了,Winform控件网上也没有多少使用教程,大部分都是自己在网上零零散散的学的,大部分用的熟了,不总结会很容易忘得. ...

  3. DropDownList控件

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

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

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

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

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

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

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

  7. IOS学习笔记(四)之UITextField和UITextView控件学习

    IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...

  8. DevExpress控件学习总结(转)

    DevExpress控件学习总结   1.Navigation & Layout 1.1 Bar Manager 如果想在窗体或用户控件(user control)上添加工具条(bars)或弹 ...

  9. Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果

    前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...

随机推荐

  1. Samba在CentOS下的图形化界面的安装

    第一步:构建yum仓库(在此用的是北交大的yum仓库) 打开目录/etc/yum.repos.d下的CentOS-Base.repo文件,此处是我自己建的yum仓库,修改里面的链接地址为北交大的镜像的 ...

  2. Ubuntu常用命令整理

    最近开始用Ubuntu系统了,各种命令很不熟练,想收集一下,以便以后查阅,用这个时常更新的随笔 1.Ubuntu设置与修改用户密码 设置ROOT密码方法:sudo passwd root ,然后输入密 ...

  3. wcf综合运用之:大文件异步断点续传

    在WCF下作大文件的上传,首先想到使用的就是Stream,这也是微软推荐的使用方式.处理流程是:首先把文件加载到内存中,加载完毕后传递数据.这种处理方式对小文件,值得推荐,比如几K,几十k的图片文件, ...

  4. LitJson解析遇到的坑

    今天在些项目的时候,遇到一个坑,现在跟大家分享一下 我遇到的错误是MissingMethodException: Method not found: 'Default constructor not ...

  5. gdb 命令使用

    1.gdb -x command.txt 每次重复输入命令很麻烦,可以使用上面的命令,把命令输入进command.txt里面,然后直接就可以执行gdb. 2.list 2.1 list functio ...

  6. 一句话美化你的下拉框之jQuery.selectMM插件

    之前很喜欢 jquery.Dropkick 这个老外美化框插件,但是:IE情况下如果数据多滚动条出现的时候就滚不了,作者也没修复 于是准备自己写一款(确切的说是修改一款吧!!).这款插件是在16素材网 ...

  7. java.util.MissingResourceException解决策

    .properties文件放到当前目录下会报错: 需要放到src文件夹下:

  8. git配置ssh

    $ git config --global user.name "yourname"$ git config --global user.email "youremail ...

  9. idea修改文件名后出现main method should be static错误

    1.确保你有main方法 2.别忘了main方法里还有参数: String[] args

  10. html字符实体对照表