dynamic datagrid at runtime c#

broberts_23

New member
Joined
Jun 26, 2003
Messages
1
I am trying to build a datagrid to display customer information at runtime. I am getting an error from the code below:


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Windows.Forms;


//Binding the data
dSet = new DataSet();
myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
dGrid.Visible = true;

dAdapter = new SqlDataAdapter(dQuery, myConnection);


dAdapter.Fill(dSet, "Customer");

dGrid.DataSource = dSet.Tables["Customer"].DefaultView;
dGrid.DataBind();


DataGridTableStyle tStyle = new DataGridTableStyle();
tStyle.MappingName = "Customer";

DataGridColumnStyle idCol = new DataGridBoolColumn();
idCol.HeaderText = "ID";

idCol.MappingName = "Current";
idCol.HeaderText = "ID";
idCol.ReadOnly = true;
idCol.Width = 200;


tStyle.GridColumnStyles.Add(idCol);


dGrid.TableStyles.Add(tStyle); *** Iget an error here its says:

System.Web.UI.Controls.DataGrid does not contain a definition for TableStyles

can anyone shed some light on this?
 
If you want the TableStyles property it sounds like you want the Windows Forms datagrid rather than the Web Forms datagrid youre trying to use at the moment.
 
Back
Top