Click here to Skip to main content
Rate this: bad
good
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 22:18pm
jawad59422

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 at 25-Sep-12 5:10am
   
Grid.DataBind() is not for Winform
_Amy at 25-Sep-12 5:20am
   
DataBind is there in Asp.Net not in winforms.
bhargavpp at 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
0 OriginalGriff 324
1 Maciej Los 239
2 Sergey Alexandrovich Kryukov 182
3 CPallini 120
4 Richard MacCutchan 120
0 OriginalGriff 5,474
1 Sergey Alexandrovich Kryukov 4,713
2 Peter Leow 2,944
3 DamithSL 2,465
4 Maciej Los 2,434


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