Click here to Skip to main content
15,884,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Issue in binding multiple combobox and datagrid at a time. It just binds the last comobox/datagrid.
C#
SetConnection(); 
			sql_con.Open();

			sql_cmd = sql_con.CreateCommand();
            string CommandText = "SELECT MediaArticle.id, MediaArticle.Title,MediaArticle.Author,MediaArticle.Volume,MediaArticle.Location, Category.Category, MediaType.Title as 'Media Type', MediaArticle.Comments, MediaArticle.UpdateDate as 'Add Date', Admin.Username as 'Added By' FROM MediaArticle INNER JOIN Admin ON MediaArticle.ById = Admin.id INNER JOIN MediaType ON MediaArticle.MediaType = MediaType.id INNER JOIN Category ON MediaArticle.Category = Category.id";
			DB = new SQLiteDataAdapter(CommandText,sql_con);
            DS.Reset();
			DB.Fill(DS);
			DT= DS.Tables[0];
			Grid.DataSource = DT;
            ex.ExportDetails(DT, Export.ExportFormat.CSV, "MediaArticles");
			sql_con.Close();


 SetConnection();
            sql_con.Open();
            sql_cmd = sql_con.CreateCommand();
            string CommandText1 = "SELECT * from MediaType";
            DB = new SQLiteDataAdapter(CommandText1, sql_con);
            DS.Reset();
            DB.Fill(DS);
            DT1 = DS.Tables[0];
            dlMediatype.DataSource = DT1;
            dlMediatype.DisplayMember = "Title";
            dlMediatype.ValueMember = "id";
            dlSearchMediaType.DataSource = DT1;
            dlSearchMediaType.DisplayMember = "Title";
            dlSearchMediaType.ValueMember = "id";
            sql_con.Close();


from above code when placed under Form load it binds '
dlMediatype
' & '
dlSearchMediaType
' BUT not binding '
Grid
' when debugged it gives its result in datatable but not found on form. Whichever is placed as last Datatable, is binding the data/working while previous not..
Posted

1 solution

Call Grid.DataBind() method after
Grid.DataSource = DT;

I hope this is the thing which is missing in your code
 
Share this answer
 
Comments
jawad59 25-Sep-12 5:10am    
Grid.DataBind() is not for Winform
_Amy 25-Sep-12 5:20am    
DataBind is there in Asp.Net not in winforms.
bhargavpp 25-Sep-12 6:19am    
try Different Ds and dt for Gridview and Combobox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900