Formatting String in Datagrid

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Formatting String in Datagrid

    Hi guys,

    does anyone know how to format strings this way:-

    i have 1 column(unit_num) in my Datagrid which displays eg. "01-123"
    i have to display only the floor level of the unit number, the first 2
    digits(the number before the '-')

    how can i do this in the "Data Formatting Expression" of the Datagrid?


    thanks in advance,
    xianxian

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***

    xianxian Guest

  2. Similar Questions and Discussions

    1. datagrid : change the string formatting expression
      hello, i'm looking for code (C# preferably) in order to change programmatically in a datagrid the string formatting expression of one bound...
    2. Formatting Number/String Help Needed...
      Hello Friends, I am using ASP VBScript and i am trying to format a number/string. I am trying to get this: 5982749259825982 to look like...
    3. Formatting a string for entry into MySQL
      Hi, I'm trying to generate a string that contains a <br>, to insert into a MySQL table. It appears the <br> is being stripped out either just...
    4. STRING FORMATTING QUESTION
      My question is regarding strings in php. I have this form in which the user fills in a description. The problem is that if the user uses any...
    5. string formatting
      I need to convert a numeric filed NUMERIC(14,3) to a string with a (european) regional currency formatting like "1.234,56". How can I achieve this,...
  3. #2

    Default Re: Formatting String in Datagrid

    Hi there,

    You can process the string in datagrid_itemdatabound event.

    HTH
    "xianxian" <xianxian@devdex.com> wrote in message news:uA1SGvRuFHA.3236@TK2MSFTNGP14.phx.gbl...
    Hi guys,

    does anyone know how to format strings this way:-

    i have 1 column(unit_num) in my Datagrid which displays eg. "01-123"
    i have to display only the floor level of the unit number, the first 2
    digits(the number before the '-')

    how can i do this in the "Data Formatting Expression" of the Datagrid?


    thanks in advance,
    xianxian

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***


    Elton Wang Guest

  4. #3

    Default Re: Formatting String in Datagrid

    hi again,

    thanks for yr reply.
    this is what i did in ItemDataBound & it works =) thanks a lot!

    If e.Item.ItemIndex >= 0 Then

    ':: Format the DataGrid columns ::

    ':: Get the text from column to format ::
    Dim lvl As String
    lvl = e.Item.Cells(4).Text

    ':: Replace with the formatted text ::
    e.Item.Cells(4).Text = Left(lvl, 2)

    End If

    regards,
    xianxian

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    xianxian Guest

  5. #4

    Default Re: Formatting String in Datagrid

    Good work!



    More common way to distinguish datagriditem is



    If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    ListItemType.AlternatingItem Then

    ' Process



    End If



    HTH

    "xianxian" <xianxian@devdex.com> wrote in message
    news:e4ZX7ipuFHA.2212@TK2MSFTNGP15.phx.gbl...
    > hi again,
    >
    > thanks for yr reply.
    > this is what i did in ItemDataBound & it works =) thanks a lot!
    >
    > If e.Item.ItemIndex >= 0 Then
    >
    > ':: Format the DataGrid columns ::
    >
    > ':: Get the text from column to format ::
    > Dim lvl As String
    > lvl = e.Item.Cells(4).Text
    >
    > ':: Replace with the formatted text ::
    > e.Item.Cells(4).Text = Left(lvl, 2)
    >
    > End If
    >
    > regards,
    > xianxian
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***

    Elton Wang Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139