DropDownList控件学习
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控件学习的更多相关文章
- DropDownList 控件
今天打算学习下dropdownlist控件的取值,当你通过数据库控件或dataset绑定值后,但又希望显示指定的值,这可不是简单的值绑定就OK,上网搜了一些资料,想彻底了解哈,后面发现其中有这么大的奥 ...
- Winform控件学习笔记【第二天】——常用控件
背景:期末考试刚过就感冒了,嗓子火辣辣的,好难受.但是一想起要学习总结就打起精神来了,Winform控件网上也没有多少使用教程,大部分都是自己在网上零零散散的学的,大部分用的熟了,不总结会很容易忘得. ...
- DropDownList控件
1.DropDownList控件 <asp:DropDownList runat="server" ID="DropDownList1" AutoPost ...
- DropDownList 控件不能触发SelectedIndexChanged 事件
相信DropDownList 控件不能触发SelectedIndexChanged 事件已经不是什么新鲜事情了,原因也无外乎以下几种: 1.DropDownList 控件的属性 AutoPostBac ...
- 三级联动---DropDownList控件
AutoPostBack属性:意思是自动回传,也就是说此控件值更改后是否和服务器进行交互比如Dropdownlist控件,若设置为True,则你更换下拉列表值时会刷新页面(如果是网页的话),设置为fl ...
- c#中DropDownList控件绑定枚举数据
c# asp.net 中DropDownList控件绑定枚举数据 1.枚举(enum)代码: private enum heros { 德玛 = , 皇子 = , 大头 = , 剑圣 = , } 如果 ...
- IOS学习笔记(四)之UITextField和UITextView控件学习
IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...
- DevExpress控件学习总结(转)
DevExpress控件学习总结 1.Navigation & Layout 1.1 Bar Manager 如果想在窗体或用户控件(user control)上添加工具条(bars)或弹 ...
- Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果
前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...
随机推荐
- ubuntu14.04+xfce下启用fcitx,使用中文输入法
1. 安装fcitx sudo apt-get install fcitx-pinyin 2.启用fcitx 打开 setting -> Language Support -> Lang ...
- atan(正切函数)
atan函数:返回数值的余切值 原型:double atan(double x) <pre name="code" class="cpp">#inc ...
- The Use of Aliases in ElasticSearch
http://paulsabou.com/blog/2012/04/15/the-use-of-aliases-in-elasticsearch/ https://github.com/taskrab ...
- Codeblock解决注释乱码问题及在ubuntu中程序运行时乱码问题。
(1)修改源文件保存编码在:settings->Editor->gernal settings>other settings 看到左边的Encoding group Box,改为WI ...
- zombie-phantom
zombie-phantom zombie-phantom Provides a Zombie.js shim around the PhantomJS Headless Browser. npm i ...
- nodejs - json序列化&反序列化示例
// demo-json.js var obj = { "name": "LiLi", "age": 22, "sex" ...
- maven项目启动
1服务install 2 build (tomcat:run)
- python中变量命名
一 综述: 二 全局变量(包含函数和类): (1)正常变量x: *通过module.x能够使用. *通过from module import *能够使用. (2)以"_"开头变量 ...
- 虎说:bootstrap源码解读(重置模块)
------<!--action-->------ 开场show:前不生“不犹豫”,后半生“不后悔”.今天又逃课,我不后悔 素材:推特公司的前端框架bootstrap(下称bt),解读源码 ...
- CodeForces 452C Magic Trick (排列组合)
#include <iostream> #include <cstdio> #include<cmath> #include<algorithm> us ...