re-ordering rows/records in datagrid

  • Thread starter Thread starter Patrick.O.Ige
  • Start date Start date
P

Patrick.O.Ige

I would like to re-order my rows in the datagrid.
So on each row i want to have up and down images to go up one row or down
Whats the easiest way to tackle this?
Any sample guides are welcome.
 
Thanks Phillip for the email and the hint and the approach
Will i be able to bind it to a table with this structure
id doc rank
1 a.doc 1
2 b.doc 2
3 c.doc 3
4 d.oc 4

What i really want to achieve is to be able to rank the doc files on
that table from 1-4 with no duplicates.
Would it be easy to retrieve my data from the database table to achieve
the same result?
Patrick
 
Hello Patrick,

Sorting based on a Rank field might eliminate the issue you encountered to
save the datatable. Try this demo:

http://www.webswapp.com/codesamples/aspnet20/datatable_rowsreorder_ondatagrid/sort_on_rank.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


Patrick.O.Ige said:
Phillip i have taken time to look at your interesting sample
and i could move up and down the row using values from a table in the DB but
i need to update changes to the table
I hooked it up with a submit button but it doesn't change the values
any ideas.. sleeping.:(:(

void Bind()
{
if (Session["FilesOrder"] == null)
{
dt = new DataTable("FilesOrder");
const string strSQL = "select * from FilesOrder";
SqlCommand myCommand = new SqlCommand(strSQL, myConnection);
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
myConnection.Open();
myAdapter.Fill(dt);
Session["FilesOrder"] = dt;
}
else
{
dt = (DataTable)Session["FilesOrder"];
}


Rote Rote said:
Thanks Phillip for the email and the hint and the approach
Will i be able to bind it to a table with this structure
id doc rank
1 a.doc 1
2 b.doc 2
3 c.doc 3
4 d.oc 4

What i really want to achieve is to be able to rank the doc files on
that table from 1-4 with no duplicates.
Would it be easy to retrieve my data from the database table to achieve
the same result?
Patrick
 
Thanks alot Phillip
I would try that out

Phillip Williams said:
Hello Patrick,

Sorting based on a Rank field might eliminate the issue you encountered to
save the datatable. Try this demo:

http://www.webswapp.com/codesamples/aspnet20/datatable_rowsreorder_ondatagrid/sort_on_rank.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


Patrick.O.Ige said:
Phillip i have taken time to look at your interesting sample
and i could move up and down the row using values from a table in the DB
but
i need to update changes to the table
I hooked it up with a submit button but it doesn't change the values
any ideas.. sleeping.:(:(

void Bind()
{
if (Session["FilesOrder"] == null)
{
dt = new DataTable("FilesOrder");
const string strSQL = "select * from FilesOrder";
SqlCommand myCommand = new SqlCommand(strSQL, myConnection);
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
myConnection.Open();
myAdapter.Fill(dt);
Session["FilesOrder"] = dt;
}
else
{
dt = (DataTable)Session["FilesOrder"];
}


Rote Rote said:
Thanks Phillip for the email and the hint and the approach
Will i be able to bind it to a table with this structure
id doc rank
1 a.doc 1
2 b.doc 2
3 c.doc 3
4 d.oc 4

What i really want to achieve is to be able to rank the doc files on
that table from 1-4 with no duplicates.
Would it be easy to retrieve my data from the database table to achieve
the same result?
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top