All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
温故知新ASP.NET,2.0(C#)(8),-,DataSourceControl(数据源控件)_[Asp.Net教程]
SQL,通配符_mssql学习_编程技术
ASP.NET技巧:投票结果的图片进度条显示_[Asp.Net教程]
使用Control,Adapters优化Asp.net控件_.net资料_编程技术
PHP加密文本文件并限制特定页面的存取_php资料_编程技术
VB.NET使用OracleTransaction处理事务_[Asp.Net教程]
Access,通用数据访问类(asp.net,2.0,c#)_[Asp.Net教程]
解决方案:用户sa登录失败_[SQL,Server教程]
ASP.NET技术中常见问题详细解答及代码_[Asp.Net教程]
ASP.NET2.0数据库入门之SqlDataSource_[Asp.Net教程]
Reading number is top 10 pictures
The dog buy the ham oneself
看看什么叫美景
Go to the national museum2
大人物的礼物
NeedWallpaper10
不知名的美女素颜照1
八个盛产美女的国家2
Wear bikinis cock
ashlynn brooke
重口味人造肉
Download software ranking
XML+Web+Service开发教程
linux安装大全
Boxer Classic video3
尖东毒玫瑰A
Boxer vs Yellow1
Proficient in JavaScript
WebService在.NET中的实战应用教学视频 → 第3集
Dance with duck(male prostitution)
SP4 for SQL2000
尖东毒玫瑰B
归海一刀 published in(发表于) 2014/1/30 1:27:50 Edit(编辑)
GridView中嵌套DropDownList的实现_[Asp.Net教程]

GridView中嵌套DropDownList的实现_[Asp.Net教程]

GridView中嵌套DropDownList的实现_[Asp.Net教程]
效果图:


后台代码:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
SqlConnection sqlcon;
string strCon = "Data Source=(local);Database=北风贸易;Uid=sa;Pwd=sa";
protected void Page_Load(object sender, EventArgs e)
{
DropDownList ddl;
if (!IsPostBack)
{
string sqlstr = "select top 5 * from 飞狐工作室";
sqlcon = new SqlConnection(strCon);
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds = new DataSet();
sqlcon.Open();
myda.Fill(myds, "飞狐工作室");
GridView1.DataSource = myds;
GridView1.DataBind();
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
DataRowView mydrv = myds.Tables["飞狐工作室"].DefaultView[i];
if (Convert.ToString(mydrv["员工性别"]).Trim() == "True")
{
ddl = (DropDownList)GridView1.Rows[i].FindControl("DropDownList1");
ddl.SelectedIndex = 0;
}
if (Convert.ToString(mydrv["员工性别"]).Trim() == "False")
{
ddl = (DropDownList)GridView1.Rows[i].FindControl("DropDownList1");
ddl.SelectedIndex = 1;
}
}
sqlcon.Close();
}
}
public SqlDataReader ddlbind()
{
string sqlstr = "select distinct 员工性别 from 飞狐工作室";
sqlcon = new SqlConnection(strCon);
SqlCommand sqlcom = new SqlCommand(sqlstr, sqlcon);
sqlcon.Open();
return sqlcom.ExecuteReader();
}

前台主要代码:

CellPadding="3" Font-Size="9pt" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px">






’ DataValueField="员工性别" DataTextField="员工性别">













添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.