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

Recommended Answers

All 5 Replies

Well, what have you tried so far? the helpfile has full examples of putting data in a datagrid

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

it is simple
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.

hi,

thank you. this one is i needed,

please marked this thread as solved

using System;
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();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.