| | |
How to show data in Datagridview in C#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2009
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Hi, im not getting of how to vies the data in the database when user select the cndidate id from combobox and the data should be shown in the datagridview. let me know the source code of the problem..
Regards,
Abhishek
all you have to do is add columns in the data grid form the UI. Then in the code you need to assign the value as
dataGridView1.Rows.Add(<value>,<value>,<value>,.....);
the no of value will be equal to the no of columns and you have to give string values.....
i hope this solves your prob..
you can also assign DataGridView's DataSource property any data source like dataTable it will take care of creating required column and filling data.
Try out any of the solution given here in thread, and if any problem get back. If you will tell what so far you have done as LizR told, it will be helpful for us to understand your problem.
Try out any of the solution given here in thread, and if any problem get back. If you will tell what so far you have done as LizR told, it will be helpful for us to understand your problem.
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Indian Developer
http://falaque.wordpress.com/
•
•
Join Date: Feb 2009
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Hi, im not getting of how to vies the data in the database when user select the cndidate id from combobox and the data should be shown in the datagridview. let me know the source code of the problem..
Regards,
Abhishek
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Data : System.Web.UI.Page
{
SqlConnection con;
SqlDataAdapter sda;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = "Data Source=.;Database=Train;User Id=sa;Password=chi";
con.Open();
sda = new SqlDataAdapter("select * from RegistrationForm", con);
ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
![]() |
Similar Threads
- get the selected row in datagridview (VB.NET)
- Read Data From MS Excel 2007 (C#)
- comparison of distinct field values in 2 tables in the datagridview (VB.NET)
- Help regarding images in datagridview (C#)
- OLeDb Connection fail (C#)
- the form won't show.. (C#)
- Why wont datagridview commit updatess? (C#)
- Datagridview problem (VB.NET)
Other Threads in the C# Forum
- Previous Thread: How do you make a heart shaped control ?
- Next Thread: multiplying two text boxes and putting answer in third text box
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagridview dataset datetime degrees development draganddrop drawing encryption enum excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






