Get column name from web config and filter the data table

Hi,

There is a scenario where I want to get specific columns from data tables. Where the data table column is define in web config file…

This is to make data table more dynamic and get only required columns from n number of columns.

Ex.

Web config
Data table columns | I’d,Name,age

Data table
I’d, Name,Age, adress, phone number

Based on the columns define in web config I want to fetch only those columns i.e. id , name,age

How can I achive this?

have a look on the datatable.DefaultView option

dtReduced = dtOrig.DefaultView.toTable(False, arrColNames)

arrColNames = String Array with the column names which are to keep

arrColNames can by dynamically created from web config string:
grafik

Hello @RENU_KHALKHO ,

Do you want filter some particular column of data ?

Could you please explain with the current and required data screenshots.

Hi,

Could you please explain the steps to make column name dynamically created from web config string

webconfig is about what? Which datatype?

Hello Rahul,

I want to get only specific columns from the data table dynamically.

Dynamically from web config there I will mention the columns name…so in future if i want extra col. I need to edit in config only

Will store the columns in dictionary type of list

please be more specific. A Dictionary of String, Object where the columnames are stored as as string like: ID,Name,Age?

then you can retrieve the column name array as described above or with some enhancements like:

grafik

YourStringVar.Split({","},StringSplitOptions.RemoveEmptyEntries).Select(Function (x) x.Trim).toarray

Thank you for your response.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.