gridview 可以在aspx.cs里面绑定数据吗?谢谢
这是绑定DropDownLis的绑定,怎么为gridview绑定要显示的值呢SqlConnectioncon=newSqlConnection("datasource=....
这是绑定DropDownLis的绑定,怎么为gridview 绑定要显示的值呢
SqlConnection con = new SqlConnection("data source=.; Initial Catalog=myPetShop; Integrated Security=true;");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select top 20 SuppId,Name from Supplier order by Name asc";
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
ddlProSupply.Items.Add(new ListItem(sdr["Name"].ToString(), sdr["SuppId"].ToString()));
}
con.Close(); 展开
SqlConnection con = new SqlConnection("data source=.; Initial Catalog=myPetShop; Integrated Security=true;");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select top 20 SuppId,Name from Supplier order by Name asc";
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
ddlProSupply.Items.Add(new ListItem(sdr["Name"].ToString(), sdr["SuppId"].ToString()));
}
con.Close(); 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询