Hiii,
I have a datagrid, to which I haved assigned values from database. Now using up/down buttons from column header i am trying to sort grid, but it is not doing sorting properly....
Example: i have column named LoanId. there are id's like 1,2...10,11...20...
now if i click on column Header Loan Id den it gives me result as 1,10,2,20,.....
i want result as 1,2,...10,11,....
can anyone help me?
thx n Regards
Amruta
Loading

VulpesRank #55 · 29.2K reputationPosted Sep 2, 2011, 4:51 AM EDT
To sort it the way you want, it needs to be an int column.
Alternatively, you could change the format of the strings to "01", "02" etc.
Amruta Kirdat72 reputationPosted Sep 2, 2011, 4:59 AM EDT
Loan Id is not a string column,it is number column...
thx
VulpesRank #55 · 29.2K reputationPosted Sep 2, 2011, 5:31 AM EDT
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 2, 2011, 5:40 AM EDT
Note: Please Don't copy the controls from other app and paste it in current apps.Rather drag and drop it from the toolbox.
Try this -
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from student";
com = new OleDbCommand(str, con);
oledbda = new OleDbDataAdapter(com);
ds = new DataSet();
oledbda.Fill(ds, "student");
DataView dv = new DataView(ds.Tables["student"]);
dv.Sort = "sid desc";
dataGrid1.DataSource = dv;
con.Close();
Thanks
Sam HobbsRank #107 · 20.5K reputationPosted Sep 2, 2011, 10:05 AM EDT
So what is it? Is the applicaiton a Windows Forms application using a DataGridView or an ASP .Net applicaiton using a DataGrid or is it something else?
Amruta Kirdat72 reputationPosted Sep 2, 2011, 8:44 PM EDT
it's a windows application....
thx
Amruta Kirdat72 reputationPosted Sep 2, 2011, 8:56 PM EDT
@vulpes : at from load i have assigned ValueType property as u mentioned...but still it's not working...
steps wht i hve done till now
1. Datagridview columns property has different columns such as LoanId,CustomerName....
2. Fetched data in dataset and assiged to columns
3. at load i set valuetype property of column 0 to int
Code
at btnSearch:
grdCustLoanDetail.Rows[i].Cells[0].Value = dsSearch.Tables[0].Rows[i]["LoanId"].ToString();
at Load
grdCustLoanDetails.Columns[0].ValueType = typeof(int);
still prob is same
thx
VulpesRank #55 · 29.2K reputationPosted Sep 3, 2011, 11:44 AM EDT