Well, after doing some search in msdn.microsoft.com I found that column "Discontinued" is one of the columns in PRODUCTS table in the NORTHWIND DATABASE. So, using it here did not make sense. Also a check box column (to make it clear - an unbound column) cannot be directly added to the Datagrid. I have added a column to the datatable and then changed the Table stlye.
On Jan 12, 1:37 pm, Karthikeyan R <[email protected]> wrote: > Hi, > > I am using dot net framework: 1.1 & VS-2003 > > I am working on a task in which I have to add to a check box column to a > Datagrid. I did spend some time in finding the way & I did make an attempt > with the following > link,http://www.vbdotnetheaven.com/UploadFile/sridhar_msd/CustomizingDatag... > however I am not able to add it. Please find below the code I have used, > In the Load event I am calling the following method, > > private void PopulateDataGrid() > > { > > try > > { > > String Query; > > DataSet Ds_Grid = new DataSet();; > > OracleDataAdapter Ora_DA; > > OracleConnection OraConn = new OracleConnection("Data Source=" + > CommonClass.ServerName + ";User Id=" + CommonClass.UserID + ";Password=" + > CommonClass.Password + ";"); > > OraConn.Open(); > > Query="Select Title,rpt_user_name from rptreport where RPT_USER_NAME = > 'RPT_DEFAULT_USER' and Title like 'Confirmation%'"; > > Ora_DA = new OracleDataAdapter(Query,OraConn); > > Ora_DA.Fill(Ds_Grid,"Tbl_ConfRptReports"); > > if (Ds_Grid.Tables["Tbl_ConfRptReports"].Rows.Count > 0) > > { > > dataGrid_Confirmations.DataSource= Ds_Grid.Tables["Tbl_ConfRptReports"]; > > } > > OraConn.Close(); > > DataGridTableStyle Tabstyle = new DataGridTableStyle(); > > Tabstyle.MappingName = "rptreport"; > > DataGridBoolColumn ChkCol = new DataGridBoolColumn(); > > ChkCol.MappingName="Discontinued"; > > ChkCol.HeaderText="Select"; > > ChkCol.Width=30; > > ChkCol.AllowNull=false; > > Tabstyle.GridColumnStyles.Add(ChkCol); > > DataGridTextBoxColumn TBCol1 =new DataGridTextBoxColumn(); > > TBCol1.MappingName="Title"; > > TBCol1.HeaderText="Report Title"; > > Tabstyle.GridColumnStyles.Add(TBCol1); > > DataGridTextBoxColumn TBCol2 =new DataGridTextBoxColumn(); > > TBCol2.MappingName="rpt_user_name"; > > TBCol2.HeaderText="User Name"; > > Tabstyle.GridColumnStyles.Add(TBCol2); > > //dataGrid_Confirmations.TableStyles.Clear(); > > dataGrid_Confirmations.TableStyles.Add(Tabstyle); > > } > > catch (Exception Ex) > > { > > MessageBox.Show(Ex.Message,CommonClass.ApplicationName,MessageBoxButtons.OK > ,MessageBoxIcon.Information);; > > } > } > > Can some one point me where I have done the mistake? > > -- > Thanks & Regards, > Karthikeyan
