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. android入门——UI(5)

    最近时间实在匆忙,博客的代码基本没有解释. 介绍ExpandableListView <?xml version="1.0" encoding="utf-8&quo ...

  2. Xposed学习

    刚接触,不是太懂,就昨天root荣耀6就花了一天时间,其实root早就ok,只是因为Xposed框架总是提示红色警告,以为不好用,后来试了几次发现,跟手机也有很大关系,有的不能很好的支持框架,有的模块 ...

  3. const和readonly你真的懂吗?

    第二遍文章我打算把const和readonly的区别拿出来讲下,因为写代码这么久我都还没搞清楚这两者的区别,实在有点惭愧,所以这一次我打算搞清楚它. 定义 来看看MSDN的解释: readonly:r ...

  4. BZOJ 4197: [Noi2015]寿司晚宴( dp )

    N^0.5以内的质数只有8个, dp(i, j, k)表示用了前i个大质数(>N^0.5), 2人选的质数(<=N^0.5)集合分别为j, k时的方案数. 转移时考虑当前的大质数p是给哪个 ...

  5. mysql的触发器

    删除触发器 drop TRIGGER 触发器名字; 查找库里面的所有触发器 SELECT * FROM information_schema.`TRIGGERS`;show triggers 触发器语 ...

  6. springmvc的ModelAndView的简单使用

    参考:http://blog.csdn.net/zzjjiandan/article/details/34089313 先上图: MAVTest.java package com.wyl; impor ...

  7. 插入数据,返回最新id

    最简单的方法就是在查询之后select @@indentity. sql代码: INSERT INTO table_name (.....) VALUES(......)  SELECT @@IDEN ...

  8. safari的调试工具

    safari的调试工具默认是没有打开的设置——>偏好设置——>高级———>在菜单栏中显示开发菜单

  9. tpopela/vips_java

    tpopela/vips_java Implementation of Vision Based Page Segmentation algorithm in Java

  10. AppStore被拒原因及总结

    4.5 - Apps using background location services must provide a reason that clarifies the purpose of th ...