2
我想设置数据源为我的绑定字段的项目,但我没有这样做,我的输出还不如我预期的设置GridView控件绑定列在ASP.Net
输出
绑定列的userName movieComment
预期输出
绑定列
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmdReadComment = new SqlCommand("SELECT [userName],[movieComment] FROM [movieCommentTable] WHERE [movieTitle]='" + lblHeadTitle.Text + "'", conn);
SqlDataReader dtrReadComment;
conn.Open();
dtrReadComment = cmdReadComment.ExecuteReader();
GridView2.DataSource = dtrReadComment;
GridView2.RowStyle.Height = 200;
BoundField userNameBF = new BoundField();
userNameBF.DataField = "userName";
userNameBF.ItemStyle.Width = 180;
GridView2.Columns.Add(userNameBF);
GridView2.DataBind();
它真正的工作,感谢 – 2012-02-07 05:01:07
我只能接受乌拉圭回合在明年8分钟答案,但顺便说我要去了,所以我只会在我接受UR答案回=) – 2012-02-07 05:01:44
没问题...很高兴为你效劳。你可以upvote?从来没有问过任何问题,所以不知道应用的限制。 – 2012-02-07 05:02:51