grid view not displayed

Posted by Deepakji under C# on 1/29/2012 | Points: 10 | Views : 1089 | Status : [Member] | Replies : 5
hi i am working on datagridview i am showing the code but its not displaying in windows application so please let me know its urgent
thank you.

namespace datagridw
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}



private void button1_Click(object sender, EventArgs e)
{
load();
}
private void load()
{

SqlConnection con = new SqlConnection("User id=sa; Password=123; Initial Catalog=bts; Data Source=fff");
SqlDataAdapter da = new SqlDataAdapter("select *from Login", con);
DataSet dr = new DataSet();
BindingSource bs = new BindingSource();
da.Fill(dr,"order");
SqlCommandBuilder bt = new SqlCommandBuilder(da);
bs.DataSource = ds.Tables["order"];
dataGridView1.DataSource = bs;
}
}
}


on window the data need to be displayed but its not .




Responses

Posted by: Arefin on: 1/29/2012 [Member] Starter | Points: 25

Up
0
Down
Try with the simple way
http://www.dotnetperls.com/datagridview-tutorial


Thanks,
Arefin

Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 1/29/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Can you change your "load" function with below and try
private void load() 

{

SqlConnection con = new SqlConnection("User id=sa; Password=123; Initial Catalog=bts; Data Source=fff");
con.open();
SqlDataAdapter da = new SqlDataAdapter("select *from Login", con);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource =ds;
dataGridView1.DataMember = ds.Tables[0].TableName;
}


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Deepakji on: 1/30/2012 [Member] Starter | Points: 25

Up
0
Down
thank you

Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Deepakji on: 1/30/2012 [Member] Starter | Points: 25

Up
0
Down
thank you but now i want to know how to update the row in windows application .

Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 1/30/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

If my answer helps you , please mark as answer.
Please check this link http://khanrahim.wordpress.com/2010/04/10/insert-update-delete-with-datagridview-control-in-c-windows-application/ for update the row.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response