下面是用DataSet绑定Gridview1的一个实例:        DataSet ds = Socut.Data.ExecuteDataSet("select * from wyx_text ORDER BY wyx_id DESC");
        GridView1.DataSource = ds;
        GridView1.DataBind();
请问,如何获取表wyx_text某一列的值???

解决方案 »

  1.   

    [code=C#]
            string newsid = Request.Params["newsID"].ToString();
            con.Open();
     
            SqlCommand cmd=new SqlCommand("select * from dbnews where newsID=1",con);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                lbHead.Text = dr[1].ToString();
                lbTime.Text=dr[3].ToString();
                lbContent.Text=dr["newscontent"].ToString();
            }
    [code]
    dr取得一列值
      

  2.   

                    string   newsid   =   Request.Params["newsID"].ToString(); 
                    con.Open(); 
      
                    SqlCommand   cmd=new   SqlCommand("select   *   from   dbnews   where   newsID=1",con); 
                    SqlDataReader   dr   =   cmd.ExecuteReader(); 
                    if   (dr.Read()) 
                    { 
                            lbHead.Text   =   dr[1].ToString(); 
                            lbTime.Text=dr[3].ToString(); 
                            lbContent.Text=dr["newscontent"].ToString(); 
                    } 
      

  3.   

    你什么意思? 
    直接在sql语句中提取不久行了吗?
    ====
    用dataview也行。
    DataView dv=new DataView(ds.Tables[o]);
    dv.RowFileters="";//可以放置查询条件,如id=0 等等
    ====
    代码手工拼写,不确保正确。
      

  4.   

    DataSet   ds   =   Socut.Data.ExecuteDataSet("select  列名   from   wyx_text   ORDER   BY   wyx_id   DESC"); 
      

  5.   

    我用的是数据库连接组件(socut.data.dll)由于后台管理文章页面需要同时打开两个表,所以打开文章表时,提取里面栏目列的值,再到栏目表里调取栏目名称显示出来
      

  6.   

    1.可以考虑改写Socut.Data.ExecuteDataSet(sql语句); 中的sql来查询得到
    2.通用的直接使用dataset.datatables[0].rows[i][j]来获取
      

  7.   

    ds.Tables[0].Rows[0];  //0表示第一列
    或者ds.Tables[0].Rows["FLD_NAME"];
      

  8.   

    我是用GridView绑定显示文章列表,其中有一列是栏目,而栏目的名称在另一张表里的classname列,现在由于GridView绑定之后无法显示文章对应的栏目,所以才有这个问题