Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ListView Control should display records of a SQL Table depending on a Query.
It should have the Column headings and when we press the down arrow it should select all the columns of the rows.

please tell to what will be code to get the value of a particular cell using static Column no. and dynamic rows no. at run time.

thanks in advance.
Posted

If you're having problems in filling the listview, perhaps this would help: http://www.akadia.com/services/dotnet_listview_sort_dataset.html[^]

About the selection, you can use ListView.SelectedItems Property [^]. Then you can either get the value from the proper subitem or perhaps it would be better to get it from the datatable.
 
Share this answer
 
Comments
[no name] 21-Dec-11 15:04pm    
Thanks for the reply mika.
I will try the process.
Wendelius 21-Dec-11 15:09pm    
You're welcome :) Hopefully it helps.
SQL
select column_name from information_schema.columns
where table_name = 'MenuItems'
order by ordinal_position


Above query will retrun the column names belong to specific table

http://doitdotnet.wordpress.com/2011/12/21/how-to-get-all-field-names-in-a-table-using-sql-query/[^]

You can get the column names using the above query by passing the table as a parameter. then in the selected index changed you can pass the column name paramter to a query which will return all the values of that column in table rows
 
Share this answer
 
Comments
[no name] 21-Dec-11 14:04pm    
Thanks for your Reply.
Query is executing perfectly.
but values are creating problem for me.
what I want is to Fill the listView in a way that it will look like a DataGridView Control.
Thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900