注册 登录
编程论坛 ASP.NET技术论坛

datagrid 数据绑定

wxm198427 发布于 2009-11-16 09:27, 729 次点击
各位,代码是这样写的
string conn=System.Configuration.ConfigurationSettings.AppSettings["conn"];//获得config的数据员
            SqlConnection sc=new SqlConnection(conn);
            sc.Open();
            SqlCommand sco = (SqlCommand)sc.CreateCommand();
            strSql="select * from menu";
            SqlDataAdapter adapt=new SqlDataAdapter(strSql,sc);
            DataSet ds=new DataSet();
            adapt.Fill(ds);
            myGrid.DataSource=ds.Tables[0];
            sc.Close();

请问这样写有问题吗?但就是没有显示,但数据库中确实有数据,请各位帮忙,谢谢…………
1 回复
#2
不说也罢2009-11-16 12:25
myGrid.DataSource=ds.Tables[0];
myGrid.DataBind();
sc.Close();

1