By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

VB.NET Web-App: how to show the table in a web form list box

P: 26
Hello Sam,

In a Windows form, the listview control is available but if i 'm working in a webform, i cannot find it. Can you please advise how to create a listview in a webform or what other options i have?
The following code is from windows form which i would like to use in web form as well:

Expand|Select|Wrap|Line Numbers
  1.  
  2. For Each fnditem In fnditems
  3.  
  4.                 Dim listparams(2) As String
  5.  
  6.                 listparams(0) = fnditem.Item.ItemID
  7.  
  8.                 listparams(1) = fnditem.Item.Title
  9.  
  10.  
  11.                 Dim vi As ListViewItem = New ListViewItem(listparams)
  12.  
  13.                 LstSearchResults.Items.Add(vi)
  14.             Next fnditem
  15.  
  16.  
What VB are you using? VBA(if so, which application), VB6, or VB.Net?

If you are using VB.Net, you might want to consider using a ListView control instead:
  1. Add a ListView control
  2. In the Design Mode, add two columns to the Columns property: Vegetables, Fruits
  3. In the form load event, you can load the rows:
Expand|Select|Wrap|Line Numbers
  1. ListView1.View = View.Details
  2. ListView1.Items.Add(New ListViewItem(New String() {"Tomato", "Apple"}))
  3. ListView1.Items.Add(New ListViewItem(New String() {"Cucumber", "Apricot"}))
HTH --Sam
Dec 17 '07 #1
Share this Question
Share on Google+
6 Replies


Frinavale
Expert Mod 5K+
P: 9,731
Hello Sam,

In a Windows form, the listview control is available but if i 'm working in a webform, i cannot find it. Can you please advise how to create a listview in a webform or what other options i have?
The following code is from windows form which i would like to use in web form as well:

Expand|Select|Wrap|Line Numbers
  1.  
  2. For Each fnditem In fnditems
  3.  
  4.                 Dim listparams(2) As String
  5.  
  6.                 listparams(0) = fnditem.Item.ItemID
  7.  
  8.                 listparams(1) = fnditem.Item.Title
  9.  
  10.  
  11.                 Dim vi As ListViewItem = New ListViewItem(listparams)
  12.  
  13.                 LstSearchResults.Items.Add(vi)
  14.             Next fnditem
  15.  
  16.  
I would love it if there was a web form ListView available for web applications, but right now it isn't.

Try using a GridView to solve your problem.

-Frinny
Dec 17 '07 #2

P: 26
This is also not that easy.

I have put a datagrid on my web form.

I typed the following like i do for listview in windows form:

Dim vi As DataGrid = New DataGrid(strParams)

It highlights it and tool tip says "overload resolution failed because no accessible new accepts this number of arguments"

Any help?




I would love it if there was a web form ListView available for web applications, but right now it isn't.

Try using a GridView to solve your problem.

-Frinny
Dec 17 '07 #3

Shashi Sadasivan
Expert 100+
P: 1,435
Hi,
Do u intend for the datagrid to filter rows according to the parameters that you are passing?

A datagrid generally takes in a datasource (which you can custom filter it)
and then bind the datagrid.

gridview.Datasource = mydatasource;
gridview.DataBind()
Dec 17 '07 #4

P: 26
Hello,

The following code is for a windows form and its using listview. I want to do the same thing in a web form. I was advised to use the datagrid but i 'm not sure how to use it. I will highly appreciate if you can please help.

Expand|Select|Wrap|Line Numbers
  1.  For Each fnditem In fnditems
  2.                 Dim listparams(2) As String
  3.  
  4.                 listparams(0) = fnditem.Item.ItemID
  5.  
  6.                 listparams(1) = fnditem.Item.Title
  7.  
  8.  
  9.                 Dim vi As ListViewItem = New ListViewItem(listparams)
  10.  
  11.                 LstSearchResults.Items.Add(vi)
  12.             Next fnditem
  13.  
Hi,
Do u intend for the datagrid to filter rows according to the parameters that you are passing?

A datagrid generally takes in a datasource (which you can custom filter it)
and then bind the datagrid.

gridview.Datasource = mydatasource;
gridview.DataBind()
Dec 18 '07 #5

Frinavale
Expert Mod 5K+
P: 9,731
Hello,

The following code is for a windows form and its using listview. I want to do the same thing in a web form. I was advised to use the datagrid but i 'm not sure how to use it. I will highly appreciate if you can please help.

Expand|Select|Wrap|Line Numbers
  1.  For Each fnditem In fnditems
  2.                 Dim listparams(2) As String
  3.  
  4.                 listparams(0) = fnditem.Item.ItemID
  5.  
  6.                 listparams(1) = fnditem.Item.Title
  7.  
  8.  
  9.                 Dim vi As ListViewItem = New ListViewItem(listparams)
  10.  
  11.                 LstSearchResults.Items.Add(vi)
  12.             Next fnditem
  13.  
I'm not sure what your variable FindItems is but you Bind Datasources to GridViews.

For Example,
MyGridView.DataSource = finditems
MyGridView.DataBind()

Would bind the data to the GridView.

Check out MSDN for more information on the GridView. They have lots of examples on how to use it in that article as well.

If you're using .NET Framework 1.1, GridView objects wont be made available to you. You should look into a DataGrid if that is the case.

-Frinny
Dec 18 '07 #6

Frinavale
Expert Mod 5K+
P: 9,731
Hello,

The following code is for a windows form and its using listview. I want to do the same thing in a web form. I was advised to use the datagrid but i 'm not sure how to use it. I will highly appreciate if you can please help.

Expand|Select|Wrap|Line Numbers
  1.  For Each fnditem In fnditems
  2.                 Dim listparams(2) As String
  3.  
  4.                 listparams(0) = fnditem.Item.ItemID
  5.  
  6.                 listparams(1) = fnditem.Item.Title
  7.  
  8.  
  9.                 Dim vi As ListViewItem = New ListViewItem(listparams)
  10.  
  11.                 LstSearchResults.Items.Add(vi)
  12.             Next fnditem
  13.  
I'm not sure if you have tried to use a GridView yet or not.
Could you please provide more details on what you have tried so far.

Have you considered creating your own version of the ListView using a Repeater and custom ListItem objects?

-Frinny
Dec 24 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.