Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Reply
DataGrid Sort C#
fez
Oct 27 2010 1:54 PM
2.8k
Reply
hello, i am trying to sort a data grid when adding a new row
right now, when a client adds a new row with the same ID it goes
2
1
2
3
4
5
(notice the ID 2 is at the very top of the list)
I need it to go
1
2
2
3
4
5
(the 2 needs to be below the 2 when it's added)
here is the code i have
private void AddOneRigActivity(int tempRigID, string tempRigNumber, int tempprovid, int tempDepthCatID, decimal tempOpDays, decimal tempNonOpDays, decimal tempAppDays, decimal tempETours, bool tempETSFlag)
{
int tempActivityID = GetNextActivityID();
DataRow dr = dtActivityData.NewRow();
int divisionID = CommonTool.ConvertStringToInt(DivisionDropdown.Sel ectedValue);
int selectedMonth = CommonTool.ConvertStringToInt(MonthDropdown.Select edValue);
dr["ActivityID"] = tempActivityID;
dr["DivisionID"] = divisionID;
dr["RigID"] = tempRigID;
dr["MonthID"] = selectedMonth;
dr["RigNumber"] = tempRigNumber;
dr["ProvinceID"] = tempprovid;
dr["DepthCategoryID"] = tempDepthCatID;
dr["OperatingDays"] = tempOpDays;
dr["NonOperatingDays"] = tempNonOpDays;
dr["ApplicableDays"] = tempAppDays;
dr["ElectronicTours"] = tempETours;
dr["ETSFlag"] = tempETSFlag;
dtActivityData.Rows.Add(dr);
dgData.DataSource = dtActivityData;
dgData_DataBind();
}
private void dgData_DataBind()
{
dtActivityData.DefaultView.RowFilter = "";
dtActivityData.DefaultView.Sort = "RigNumberLen, RigNumber";
//there is a reason why its sorted by RigNumberLen then Rignumber that has to stay the same
dgData.DataSource = dtActivityData;
dgData.DataBind();
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
how to pass values to the script
short checkboxlist