40分发个简单的啦

chenruoxi3001 2010-06-04 04:51:20
DAL层:
public DataSet Select1()
{
string sql = "select * from newclass";
SqlHelper help = new SqlHelper();
return help.run(sql, CommandType.Text, null);
}

SQLHelper:
public DataSet run(string cmdName, CommandType cmdType, SqlParameter[] Sqlparams)
{
myConnection = new SqlConnection(ConfigurationManager.AppSettings["SQLCONNECTIONSTRING"].ToString());
SqlCommand cmd = new SqlCommand(cmdName, myConnection);
cmd.CommandType = cmdType;

if(Sqlparams != null)
{
foreach (SqlParameter sp in Sqlparams)
{
cmd.Parameters.Add(sp);
}
}

SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}


页面我把DateSet绑定到dropdownlist上
public void Bind1()
{
DAL_NewClass dl = new DAL_NewClass();
DropDownList1.DataSource = dl.Select1().Tables[0].DefaultView;
DropDownList1.DataBind();
DropDownList1.DataTextField = "classname";
DropDownList1.DataValueField = "classid";
}


怎么显示不出数据呢?????显示 很多System.Data.DataRowView
...全文
60 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
houzhenya 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyi8808 的回复:]
DAL_NewClass dl = new DAL_NewClass();
DropDownList1.DataSource = dl.Select1().Tables[0].DefaultView;
DropDownList1.DataTextField = "classname";
DropDownList1.DataValueField = "classid";
Dr……
[/Quote]```
chenruoxi3001 2010-06-04
  • 打赏
  • 举报
回复
哈哈,,,今天aluogang帮我不少啊,,,谢谢,,
aluogang 2010-06-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyi8808 的回复:]
DAL_NewClass dl = new DAL_NewClass();
DropDownList1.DataSource = dl.Select1().Tables[0].DefaultView;
DropDownList1.DataTextField = "classname";
DropDownList1.DataValueField = "classid";
Dr……
[/Quote]
+1
zhangguofang1129 2010-06-04
  • 打赏
  • 举报
回复
晕,没抢到沙发,楼主给分
chenruoxi3001 2010-06-04
  • 打赏
  • 举报
回复
谢谢,,知道了,,,没注意,,,原来这也又关系艘
zhangguofang1129 2010-06-04
  • 打赏
  • 举报
回复
public void Bind1()
{
DAL_NewClass dl = new DAL_NewClass();
DropDownList1.DataSource = dl.Select1().Tables[0].DefaultView;
DropDownList1.DataTextField = "classname";
DropDownList1.DataValueField = "classid";
DropDownList1.DataBind();
}
wuyi8808 2010-06-04
  • 打赏
  • 举报
回复
DAL_NewClass dl = new DAL_NewClass();
DropDownList1.DataSource = dl.Select1().Tables[0].DefaultView;
DropDownList1.DataTextField = "classname";
DropDownList1.DataValueField = "classid";
DropDownList1.DataBind();

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧