c# - Trying to rearrange my listview, but not sure how to get the property I need to edit -


Then, I have a list view that contains one step in one process, on the left is a label that states that What is this step, and there is a text box with instructions on the right. Then there are general editing and delete buttons on the right side of that textbox, but I also have an up arrow and down arrow. If clicked, I think that would like a set of current items to move to that slot.

This list view is bound by a LinqDataSource and if I can use the property of an item from that set, where the button was clicked, I could just call ListView.DataBind () and call it myself Can be sorted.

The property I am talking about is in the label which is saying which stage is there. I've set it up like this:

  & lt; Asp: Label ID = "lblStepNumber" runat = "server" text = '& lt;% # Eval ("StepNumber", "step # 0}")%> '/ & Gt;  

So if I can do just that

  ListView.Items [Where_btn_clicked]. StepNumber ++; ListView.Items [Where_btn_clicked + 1] .StepNumber--. ListView.DataBind ();  

This would be the easiest, but I do not know how to use this property.

I will personally use a repeater in this case and can tie it to my LinqDataSource < / P>

You can then handle the OnItemDataBound event and get the e.Item.DataItem object for each line. Get a reference of the button above and below as the e.Item.FindControl ("btnUP") button and set the command argument of the button in the sequence number of your dynamite.

Then use the CommandArgument to re-order and update your LinqDataSource in the onclick event of the button - then reboot the repeater to display the changes.

Edit - Adding Clarity

Assume that you have a list & lt; Employee & gt; as your data source, and employee object

  public class employee {int EmployeeID; Int place inline; // signal value of the sequence status string; }  

The button above you and below can be defined in your ListView like this:

  & lt; Asp: button id = "btnUpButton" runat = "server" commandamement = '<% # Eval ("EmployeeID")% & gt; OnClick = "btnUp_Click" />  

When the button is clicked, you can handle the event - assuming you have a list of available employees in the form of a private variable:

< Pre> private list & lt; Employee & gt; _ Workers; Protected void btnUp_Click (Object Sender, EventArgs e) {button sender in the form of button btnUp =; Int employee id = int.Parse (btnUp.CommandArgument); // Get Bound PK employee toMoveUp = _Employees. Where (E => E.MPIRED = employee ID) Before and after default (); // PlaceInLine is unique among all employees ... employee toMoveDown = _Employees.Where (E => E.Placeline == toMoveUp.PlaceInLine + 1). FirstOrDefault (); // At this point you need the ++ employee sequence and // - the employees (such as 5 to 6 and 6 to 5 increments); To-to-up Placelines ++; ToMoveDown.PlaceInLine -; // Save the list DataAccessLayer.Save (_Employees); // listlist myListView.DataBind (); }

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -