Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Best way to display data in gridview

$
0
0

I am using Sql database (.mdf) in winform. I need to know which is best method to show data in gridview? Or is there any option i can use other than gridview to show data. My data is simple text and numbers.

Currently i am manually adding row to datagridview. Code is below.

SqlConnection cn = new SqlConnection(connection_string);
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
cmd.CommandText = connection_string;
dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                  //Adding row manually to gridview
                }
            }


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>