<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Pid" DataNavigateUrlFormatString="ad_showpinglun.aspx?Pid={0}" DataTextField="Pname" HeaderText="用户名" />
<asp:BoundField DataField="newID" HeaderText="评论标题" />
<asp:BoundField DataField="type" HeaderText="类型" />
<asp:BoundField DataField="Ptime" HeaderText="时间" />
<asp:BoundField DataField="pIP" HeaderText="IP" />
<asp:CommandField ShowSelectButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
private void Binddata()
{
GridView1.DataSource = bs.ds("SELECT A.newID, A.title, B.type, B.newID AS Expr1, B.Pconent,B.Pid B.Ptime, B.Pname, B.pIP FROM dbo.tb_new A INNER JOIN dbo.tb_pingl B ON A.newID = B.newID", "pinglun");
GridView1.DataBind();
}
public System.Data.DataSet ds(string Sql,string TableName)
{
SqlConnection MyConnection = CreateCon();
MyConnection.Open();
SqlDataAdapter MyCommand=new SqlDataAdapter(Sql,MyConnection);
DataSet ds=new DataSet();//定义一个数据集
MyCommand.Fill(ds,TableName);
MyConnection.Close();
return ds;
}
这个绑定不了数据,什么原因呀!
我知道应该是字段问题,但应该怎么修改呢!希望各位大哥能相助!!!