Click here to Skip to main content
15,908,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to retrieve a range of values from database in each click of a button in the form and display them in a grid
Posted
Comments
Mohamed Mitwalli 21-Jun-12 3:32am    
You can use paging and your problem will solve
dimpledevani 21-Jun-12 7:30am    
fire your query every time on button click and update you grid
ZurdoDev 21-Jun-12 8:00am    
Write the code to do it. However, this is so vague no one can help until you provide some details.
Sandeep Mewara 21-Jun-12 15:59pm    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.

1 solution

if you have an SQL table like:
Table1
int id
varchar text

make a class
C#
class Table1
{
int id;
String text;
getId();
getText();

void selectRow(int id)
{
SQLConnection sql = new SQLConnection("connectionString");
//this query is easy, but using parameters is safer
string query = "select * from Table1 where id= "+id.ToString();
//use SQLReader
if(read)
{
this.id = ???
this.text = ???
}

static List<Table1> selectAll()
{
List<Table1> list = new List<Table>();
SQLConnection sql = new SQLConnection("connectionString");
//this query is easy, but using parameters is safer
string query = "select * from Table1";
//use SQLReader
Table1 tmp;
while(read)
{
tmp= new Table1();
tmp.id = ???
tmp.text = ???

list.Add(tmp);
}

}

}//class end

form:
init()
{
listview.AddColumn("id",50);
listview.AddColumn("text",100);
}
fillListView()
{
List<Table1> tList = new List<Table1>();
tlist = Table1.selectAll();
//add to list view
}
 
Share this answer
 
v2

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