hi i want to bind data form data set into datagird view columns but i can't is there some one to help me pleaaaaaaaaaaaaaaaasssssssssssssssssseeeee

Recommended Answers

All 3 Replies

1st do not create any columns for dgv!
They will be created automatically when binding data.

Then use this code:

dataGridView1.DataSource = new BindingSource(ds.Tables[0], null);
//ds is a reference of dataSet, while Tables[0] is the 1st dataTable from DataSet.
//if you have more then one dataTable, if you want to bind 2nd table, then do: Tables[1]!

hi..

datagrid1.DataSource= ds.tables["tablename"];
DataGrid1.DataBind();

thank's for your help but its not my problem those are my codes please see it if you have time and resolve my problem

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
dataGrid_Tbl_Anbar.DataBindings.Clear();
MC.SETConnection();
con = new SqlConnection(MC.StrCon);
strSql = "Select * from Anb_Tbl_Anbar";
con.Open();
da = new SqlDataAdapter(strSql,con);
da.Fill(ds,"Anb_Tbl_Anbar");
dataGrid_Tbl_Anbar.DataBindings.Add("DataSource",ds,"Anb_Tbl_Anbar");
this line is my problem ----> dataGrid_Tbl_Anbar.DataBindings.Add("Columns[<1>].clm",ds,"Anb_Tbl_Anbar.Anb_Fld_AnbarCode"); <-------
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
i can fill the data gird view easily but i want to fill in special columns that i created before please help me

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.