We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Mapping a GridBoundColumn to the underlying DataColumn

Hi, I need to evaluate the source DataColumn datatype for some GridBoundColumns in a GridBoundColumnsCollection. Is there a way to get to the source DataColumn using a GridBoundColumn or its index within the GridBoundColumnsCollection? Thanks, Doug Lind

3 Replies

AD Administrator Syncfusion Team October 29, 2003 07:52 PM UTC

GridBoundColumn.MappingName holds the name of the DataColumn. //get the datacolumn for the 3rd col in grid string dataTableColumnName = this.gridDataBoundGrid1.GridBoundColumns[2].MappingName; DataColumn dc = this.dataTable1.Columns[dataTableColumnName];


DL Doug Lind October 30, 2003 12:24 PM UTC

Thanks for the response Clay. I was hoping to avoid having to evaluate the DataSource type (DataSet, DataTable, etc), to extract the underlying "table". In a reponse to one of my previous questions, you steered me towards using the CurrencyManager to extract the underlying DataRow based upon the grid row index. Is there some method like this for retrieving a DataColumn based upon the grid column index? Doug > GridBoundColumn.MappingName holds the name of the DataColumn. > > > //get the datacolumn for the 3rd col in grid > string dataTableColumnName = this.gridDataBoundGrid1.GridBoundColumns[2].MappingName; > DataColumn dc = this.dataTable1.Columns[dataTableColumnName];


AD Administrator Syncfusion Team October 30, 2003 03:19 PM UTC

There is a PropertyDescriptor property you can use, it it can only returns values not a whole column. //the value from the 5 item in the 3rd column. int item = 5; CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; object o = cm.List[item]; PropertyDescriptor pd = this.gridDataBoundGrid1.Binder.InternalColumns[2].PropertyDescriptor; object val = pd.GetValue(o); Console.WriteLine(val);

Loader.
Live Chat Icon For mobile
Up arrow icon