Click here to Skip to main content
12,078,795 members (52,653 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET combobox DataTable , +
Issue in binding multiple combobox and datagrid at a time. It just binds the last comobox/datagrid.
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 24-Sep-12 23:18pm
jawad59516

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Call Grid.DataBind() method after
Grid.DataSource = DT;
I hope this is the thing which is missing in your code
  Permalink  
Comments
jawad92 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160212.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100