How to format column in datacolumn

Discussion in 'ASP .Net' started by VISVAMBHAR TRIBANG RAJAT AMOL TANMAY RASIK VISHAL, Sep 1, 2006.

  1. Hi,

    I need display dropdown with data from two columns, so I am doing like this:

    DataTable source = data.GetSomeData(); //returns a datatable
    source.Columns.Add("DisplayName", typeof(string), "[EventTitle] + ' (' +
    [EventDate] + ')'");

    theDropdown.DataValueField = "IDColumn";
    theDropdown.DataTextField = "DisplayName"; //created above

    theDropdown.DataSource = source;
    theDropdown.DataBind();


    When displayed in dropdown, it shows:

    Event #1 (9/15/2006 12:00:00 AM)
    Event #2 (10/23/2006 12:00:00 AM)

    I want to not have the time in there. I know that I can change how the data
    is returned in the GetSomeData() method, and that is probably what I'll do,
    but this got me wondering how I could apply formatting to the column with
    how I'm adding it by concatenating other fields. I tried to see if ADO.Net
    used DATEPART or something like that, but it was not known.

    Thank you,
    VISVAMBHAR TRIBANG RAJAT AMOL TANMAY RASIK VISHAL BHUSHAN SUBHASH SOUMIL
    OMKAR HARSHIT SUDHIT GARUD MUKUND SHAHALAD KRIPAL SANSHRAY MEET NITYANAND
    ANGIR SUMANT SHANTANU RAM ADVAITA VISVARUP KAVIN SRINIVAS HANUMAN KEWAL
    VISVAMBHAR TRIBANG RAJAT AMOL TANMAY RASIK VISHAL BHUSHAN SUBHASH SOUMIL
    OMKAR HARSHIT SUDHIT GARUD MUKUND SHAHALAD KRIPAL SANSHRAY MEET NITYANAND
    ANGIR SUMANT SHANTANU RAM ADVAITA VISVARUP KAVIN SRINIVAS HANUMAN KEWAL HARI
    NAVADWEEP PARAN TANMAY GOPESH HARSHAD MEHUL RANAK PANAV BHIM MADAN SHYAMAL
    DAMODAR NITIN MADHUSUDAN ETASH TAKSHEEL AKSHAR AMAR ACYUTA AYUSH SRIVAS
    RASAPARAYAN SUBHASH KHUSHAL RAJDEEP PUNIT VIRAJ AGASTHYA ANUPAM.
     
    VISVAMBHAR TRIBANG RAJAT AMOL TANMAY RASIK VISHAL , Sep 1, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=

    UserControl in Template DataColumn

    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Feb 26, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    488
    Martin Dechev
    Feb 26, 2004
  2. Azkaban

    Add DataColumn to DataSet

    Azkaban, Oct 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,713
    =?Utf-8?B?bWpvZmFycmVsbA==?=
    Oct 18, 2004
  3. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    How to format Date Inside DataColumn

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Nov 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,367
    =?Utf-8?B?UHN5Y2hv?=
    Nov 4, 2004
  4. SMH
    Replies:
    0
    Views:
    883
  5. steveski
    Replies:
    3
    Views:
    828
    Ken Cox [Microsoft MVP]
    Jan 26, 2005
Loading...

Share This Page