Datagridview control in .net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siri11
    New Member
    • Sep 2007
    • 38

    Datagridview control in .net

    Hi..
    Can anyone plzzz suggest me how to bind data to Datagridview control from database (Sql server 2000) in c#.net(windows Application).I have one single record in my table,this single record must be displayed in the grid in single column.Plzz provide the code..

    Thanks in advance
    siri
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by siri11
    Hi..
    Can anyone plzzz suggest me how to bind data to Datagridview control from database (Sql server 2000) in c#.net(windows Application).I have one single record in my table,this single record must be displayed in the grid in single column.Plzz provide the code..

    Thanks in advance
    siri
    populate a datatable or dataset...set the datasource of that gridview to the table or dataset.....
    [CODE=css]
    GridView1.DataS ource = dt;
    GridView1.DataB ind();

    [/CODE]
    or,
    [CODE=css]
    GridView1.DataS ource = DataSet1.Tables (dt);
    GridView1.DataB ind();

    [/CODE]

    Comment

    • siri11
      New Member
      • Sep 2007
      • 38

      #3
      Originally posted by dip_developer
      populate a datatable or dataset...set the datasource of that gridview to the table or dataset.....
      [CODE=css]
      GridView1.DataS ource = dt;
      GridView1.DataB ind();

      [/CODE]
      or,
      [CODE=css]
      GridView1.DataS ource = DataSet1.Tables (dt);
      GridView1.DataB ind();

      [/CODE]
      Thank u so much...
      But....
      I already tried using this.but it doesn't work "DataGridVi ew" control for Windows App doesn't have the "DataBind" method.And I also think that GridView control cannot be used for Windows appln,it is for web applns.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        For DataGridView's, all you need to do is set the datasource and it will populate for you.

        Comment

        Working...