Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. DataBinder.Eval()

DataBinder.Eval()

Scheduled Pinned Locked Moved ASP.NET
helptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    peshawarcoder
    wrote on last edited by
    #1

    I hav a DataView object named dv. It gets its data from a DataTable named tbl. It has three columns: col1,col2,col3. I populate a ListBox object named lstItems from it in the following way:

    ...
    Dim dv As New DataView
    dv.Table=tbl
    lstItems.DataSource=dv
    lstItems.DataValueField="col1"
    lstItems.DataTextField=DataBinder.Eval(dv,"col2,col3")
    lstItems.DataBind()

    It want col2,col3 values to be displayed in as a single item listbox. it gives error on reaching to DataBinder.Evel() method. Can someone help me how to solve this problem. Thanks

    M P 2 Replies Last reply
    0
    • P peshawarcoder

      I hav a DataView object named dv. It gets its data from a DataTable named tbl. It has three columns: col1,col2,col3. I populate a ListBox object named lstItems from it in the following way:

      ...
      Dim dv As New DataView
      dv.Table=tbl
      lstItems.DataSource=dv
      lstItems.DataValueField="col1"
      lstItems.DataTextField=DataBinder.Eval(dv,"col2,col3")
      lstItems.DataBind()

      It want col2,col3 values to be displayed in as a single item listbox. it gives error on reaching to DataBinder.Evel() method. Can someone help me how to solve this problem. Thanks

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      You can use the DataBinder in this way as the DataTextField is where you specify a single data field. IMO, your chances are: + Manage to add the ListItem in the Items collection and you can combine the two columns. + Rearrange the datasource to have a column that is the combination of the two columns.

      P 2 Replies Last reply
      0
      • M minhpc_bk

        You can use the DataBinder in this way as the DataTextField is where you specify a single data field. IMO, your chances are: + Manage to add the ListItem in the Items collection and you can combine the two columns. + Rearrange the datasource to have a column that is the combination of the two columns.

        P Offline
        P Offline
        peshawarcoder
        wrote on last edited by
        #3

        Thank you.

        1 Reply Last reply
        0
        • M minhpc_bk

          You can use the DataBinder in this way as the DataTextField is where you specify a single data field. IMO, your chances are: + Manage to add the ListItem in the Items collection and you can combine the two columns. + Rearrange the datasource to have a column that is the combination of the two columns.

          P Offline
          P Offline
          peshawarcoder
          wrote on last edited by
          #4

          Thank you.

          1 Reply Last reply
          0
          • P peshawarcoder

            I hav a DataView object named dv. It gets its data from a DataTable named tbl. It has three columns: col1,col2,col3. I populate a ListBox object named lstItems from it in the following way:

            ...
            Dim dv As New DataView
            dv.Table=tbl
            lstItems.DataSource=dv
            lstItems.DataValueField="col1"
            lstItems.DataTextField=DataBinder.Eval(dv,"col2,col3")
            lstItems.DataBind()

            It want col2,col3 values to be displayed in as a single item listbox. it gives error on reaching to DataBinder.Evel() method. Can someone help me how to solve this problem. Thanks

            P Offline
            P Offline
            Pradipta Basu
            wrote on last edited by
            #5

            you can write a function to combine the two fields with comman and then use that function in DataTextField. like, string Combine(object o1, object o2) { return o1.ToString() + "," + o2.ToString(); } you can use lstItems.DataTextField = Combine(DataBinder.Eval(dv, "col2"), DataBinder.Eval(dv, "col3")); Thanks, Pradipta. Pradipta Basu

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups