情况是这样的:
在用DATAGRID的时候,窗体能显示表的列名,但不能显示里面 的数据

解决方案 »

  1.   

    1.表里就没有数据
    2.只设置了Head Text,没有设置Data Field
      

  2.   

    datafield设置了没设置好了直接绑定,只要表里有就应该显示的
      

  3.   

    <asp:BoundColumn DataField="content" HeaderText="内容" Visible="true">
    <HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle>
    <ItemStyle Wrap="False" HorizontalAlign="right" Width="10%"></ItemStyle>
    </asp:BoundColumn>DataField 的值要与数据库字段值一致
      

  4.   

    贴一段你的aspx页面里的datagrid的代码出来看看。
      

  5.   

    datafiled也设置了
    运行的时候页面一片空白
      

  6.   

    不好意思
    我的意思是只通过数据控件来实现
    小弟在这里说SORRY了
      

  7.   

    在page_load()里做了处理吗?
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not IsPostBack Then
                Me.SqlDataAdapter1.Fill(DataSet11)
                Me.DataGrid1.DataBind()
            End If
        End Sub
      

  8.   

    在属性生成器里看看吧
    还有,是不是你的 data source没有绑定?
      

  9.   

    有没有设置datafield?page_load()有没有databind?
    最好还是把源码贴出来
      

  10.   

    做了
    我是用C#的
    sqlDataAdapter1.Fill(dataSet41,"FJ_FileInfo");

    this.DataBind();
      

  11.   

    private void InitializeComponent()
    {
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
    this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
    this.dataSet41 = new WebApplication1.DataSet4();
    ((System.ComponentModel.ISupportInitialize)(this.dataSet41)).BeginInit();
    this.DataGrid1.Unload += new System.EventHandler(this.DataGrid1_Unload);
    this.DataGrid1.Init += new System.EventHandler(this.DataGrid1_Unload);
    this.DataGrid1.Disposed += new System.EventHandler(this.DataGrid1_Unload);
    this.DataGrid1.PreRender += new System.EventHandler(this.DataGrid1_Unload);
    this.DataGrid1.DataBinding += new System.EventHandler(this.Page_Load);
    this.DataGrid1.Load += new System.EventHandler(this.DataGrid1_Unload);
    this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_Unload);
    // 
    // sqlConnection1
    // 
    this.sqlConnection1.ConnectionString = "initial catalog=EHR;packet size=4096;integrated security=SSPI;data source=C184;pe" +
    "rsist security info=False;connect timeout=30;workstation id=C184";
    this.sqlConnection1.InfoMessage += new System.Data.SqlClient.SqlInfoMessageEventHandler(this.sqlConnection1_InfoMessage);
      

  12.   

    // sqlInsertCommand1
    // 
    this.sqlInsertCommand1.CommandText = @"INSERT INTO FJ_FileInfo(Typeid, title, Authorizer, valid, EnactDate, EnactOrg, ActDate, InvalidDate, ContentType, DocNO, keywords, text, Notes, ClassNo) VALUES (@Typeid, @title, @Authorizer, @valid, @EnactDate, @EnactOrg, @ActDate, @InvalidDate, @ContentType, @DocNO, @keywords, @text, @Notes, @ClassNo); SELECT id, Typeid, title, Authorizer, valid, EnactDate, EnactOrg, ActDate, InvalidDate, ContentType, DocNO, keywords, text, Notes, ClassNo FROM FJ_FileInfo WHERE (id = @@IDENTITY)";
    this.sqlInsertCommand1.Connection = this.sqlConnection1;
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Typeid", System.Data.SqlDbType.VarChar, 15, "Typeid"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar, 400, "title"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Authorizer", System.Data.SqlDbType.VarChar, 10, "Authorizer"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valid", System.Data.SqlDbType.Bit, 1, "valid"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EnactDate", System.Data.SqlDbType.VarChar, 10, "EnactDate"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EnactOrg", System.Data.SqlDbType.VarChar, 400, "EnactOrg"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ActDate", System.Data.SqlDbType.VarChar, 10, "ActDate"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@InvalidDate", System.Data.SqlDbType.VarChar, 10, "InvalidDate"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ContentType", System.Data.SqlDbType.VarChar, 200, "ContentType"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DocNO", System.Data.SqlDbType.VarChar, 200, "DocNO"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@keywords", System.Data.SqlDbType.VarChar, 2147483647, "keywords"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@text", System.Data.SqlDbType.NVarChar, 1073741823, "text"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Notes", System.Data.SqlDbType.VarChar, 2147483647, "Notes"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ClassNo", System.Data.SqlDbType.VarChar, 40, "ClassNo"));