Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6583265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:23:10+00:00 2026-05-25T16:23:10+00:00

I’m using a CheckBoxList to define which columns are displayed in a GridView. I

  • 0

I’m using a CheckBoxList to define which columns are displayed in a GridView. I populate the CheckBoxList using a query like

select column_name, data_type from information_schema.columns
    where table_name = 'myTable'

After the user has chosen the columns (with various Data Types in them) they wish to display, they press a button and the following snippet of VB code generates the GridView.

For Each item As ListItem In chooseColsList.Items
    If item.Selected Then
        Dim bf As New BoundField()
        'PRODUCES BUGGY RESULTS BECAUSE APPLIED TO ALL BoundFields
        bf.DataFormatString = "{0:dd-MMM-yyyy}"
        bf.ApplyFormatInEditMode = True
        bf.DataField = item.Value
        bf.HeaderText = item.Value
        bf.SortExpression = item.Value
        statusReportGrid.Columns.Add(bf)
    End If
Next

What I want to do is to apply the DataFormatString ONLY to the columns with a ‘date’ Data Type in them. However, I have found no way of programmatically determining the Type of the data in the column being bound, no any way of passing this info to the Control. This information exists in the information_schema, as shown in my query, but I don’t know how to extract that out and use it to dynamically setup my BoundFields. It is important to note that I’m using an SqlDataSource.

I’ve experimented with just about every possible solution I can think of and end up here.

Thanks in advance for your help, it is VERY appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:23:11+00:00Added an answer on May 25, 2026 at 4:23 pm

    If you set your check box list like this:

    <asp:checkboxlist id="list" runat="server"  
    DataTextField="column_name" DataValueField="data_type" DataSourceID="YourDSID" />
    

    You should be able to iterate through the items and check the value of the current Item like so:

    For Each item As ListItem In chooseColsList.Items
        If item.Selected Then
            Dim bf As New BoundField()
    
            If StrComp(item.Value,"date") = 0 Then 'Or however datetime is returned
                bf.DataFormatString = "{0:dd-MMM-yyyy}"
                bf.ApplyFormatInEditMode = True
            End If
            bf.DataField = item.Text
            bf.HeaderText = item.Text
            bf.SortExpression = item.Text
            statusReportGrid.Columns.Add(bf)
        End If
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.