Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Sir,

I am developing billing application for my client so he have some requirements like that he need to add customer location wise but when any new customer is add into the same location it wouldn't be add to the next no. instead of that he can arrange him between any of existing ID's

For Example :

let us assume we have 50 customer under 2 different locations i.e 25 customers falls under location1 1 and remaining in location 2. So now i have to add new customer at custId 2 in location 1 so how is it possible in gridview.
And when i add this customer at custId2 remaining customer Id increases by one i.e custId 3 becomes 4 and so on..

Please give me solution ASAP
Posted
Updated 18-Oct-13 21:46pm
v2
Comments
Ank_ush 19-Oct-13 10:55am    
why you want to change the cust ID, once it is given it should not change, display the data by sorting according to the location.
yogeshkansete 21-Oct-13 0:58am    
Actually this client have the cable network business so he need to print bill every month.And he want to print bill as location wise but after that he don't need again to sort out the bill.
ex.
suppose when i give print for the location 1 and i get the print as in serial no like custno 1,2,3,4..
but my customer no 3 is neighbor of customer no 1 so i need to print in 1,3,2,4..
for that reason i want to give him some sort out option in gridview because of that he can arrange customer as his own way
yogeshkansete 23-Oct-13 3:10am    
helloo...any solution for this question??

I tried this code,it removes the row which i selected but gives exception while inserting row.
Error: "Programmatically you can't insert row while the control is databind "

private void btnUp_Click(object sender, EventArgs e)
{
DataGridView grid = gridTasks;
try
{
int totalRows = grid.Rows.Count;
int idx = grid.SelectedCells[0].OwningRow.Index;
if (idx == 0)
return;
int col = grid.SelectedCells[0].OwningColumn.Index;
DataGridViewRowCollection rows = grid.Rows;
DataGridViewRow row = rows[idx];
rows.Remove(row);
rows.Insert(idx - 1, row); // getting exception here
grid.ClearSelection();
grid.Rows[idx - 1].Cells[col].Selected = true;

}
catch { }
}

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