Repeater Control / DataGrid / Row[] help

R

Ryan Ternier

I'm having the issue is when I re-bind my repeater to show the changes
done to it from the code behind.

I'm binding this repeater from a DataTable that is stored in the
ViewState for now. It might change later, but that's where I'm gettting
it from.

I have an Image Button that allows users to move a Record Up one space
(order).

My Code grabs the DataTable from the ViewState, does the changes (which
work correctly), then procedes to bind the DataTable to the Repeater.

It works all find and dandy, but it doesn't change the order. THis is
because the acual order of the rows hasn't changed at all.

So I decide to do:

Repeater.DataSource = tblTemp.Select("Order > 0","ORDER DESC");

This works, but all the column headers are now gone, and I can't do any
binding like:

((TextBox)e.Item.FindControl("txtSectionName")).Text =
(String)System.Web.UI.DataBinder.Eval(e.Item.DataItem,"Name");


Seeing the .Select of the DataGrid returns an array of Rows, is there
any other way of doing this asside from creating a brand new DataTable
from the array of rows?


/RT
 
E

Eliyahu Goldin

Ryan,

I think you should look at DataTable's PrimaryKey property. Ideally you
should have a column holding the row's order. Make it to the primary key.
When you want to change the order, you will just re-calculate the column
value for every row and re-databind. The repeater should pick up the new
order.

Eliyahu
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top