Click here to Skip to main content
15,898,659 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,

I am using Datagridview in windows application to display data. I'm using previous &

forward button to display the next & previous date. I'm in need of a code

which can traverse through the dataset & display one row of a dataset value at a time.

How do i achieve this?
Posted

1 solution

Assuming you have your DataGridView.DataSource as a DataTable:
DataView dv = myDataTable.DefaultView;
dv.RowFilter = "date='2011-03-14'";
Should do it for you...
 
Share this answer
 
Comments
[no name] 13-Jul-11 5:13am    
i cant get .. i need how get date from dataset and bind the value in grid

i have date 1-01-2011 to 1-03-2011 . In 1-01-2011 "20" or "n" number records .
For example

Datagridview i want like that

Date Value
1-01-2011 1
1-01-2011 2
1-01-2011 3
1-01-2011 4
if i click next button it want to show 02-01-11... like that

my code sample

for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{

string frmdate1 = ds.Tables[0].Rows[i][0].ToString();
string tod22 = Convert.ToDateTime(frmdate1).ToString("dd/MM/yyyy", CultureInfo.CreateSpecificCulture("en-US"));
string[] spt22 = tod22.Split('/');
frmdate = "" + spt22[2].ToString() + "-" + spt22[1].ToString() + "-" + spt22[0].ToString() + "";
string sql = "select ldate as Date from " + tablename + " where ldate= '" + frmdate + "' order by ldate ASC";
SQLiteDataAdapter da = new SQLiteDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
DataView dataView = ds.Tables[0];

}
I want show 1-01-2011 ,2-01-2011....like that i have place two button next and previous if i click i want show iterative date in grid

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