DataBinder.Eval()
-
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
-
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
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.
-
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.
Thank you.
-
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.
Thank you.
-
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
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