c# - Is there a way to get the ID of a select button from the EventArgs of a ListView SelectedIndexChanged? -


I have two buttons in a list view that adjust the position of that item, basically, take it up Or it takes it down in both the buttons there is CommandName = "select" , so I have to know that their ID is anywhere in EventArgs, so I can tell that the button above or below was pressed .

This is my temporary soul, maybe it will give you a better idea what I mean.

  int s; Public Zero iBtnUp_Click (Object Sender, EventArgs e) {s = 1; } Public Zero iBtnDown_Click (Object Sender, EventArgs e) {S = 0; } Public Zero lvSteps_electedIndexChanged (Object Sender, EventArgs e) {DataKey currentDataKey = this.lvSteps.DataKeys [lvSteps.SelectedIndex]; Int id = (int) Current data. Values ​​[0]; Int step = (int) Current data. Evaluations [1]; ClsProcessStep newProcessStep = new clsProcessStep () {ProcessStepID = ID, StepNumber = step}; NewProcessStep.swapSteps (s); }    

with command name On the / code> button if you apply a unique command argument for each button, in your event handler you can determine which button was clicked.

However this will not be selected, if using the selected Ink Exchange event. The reason for this is that the EventArgs parameter does not include the command name and logic description. Instead you may have to switch to the onetime command handler. It uses the ListViewCommandEventArgs in the signature so that you can get the CommandName and CommandArgument properties out of it.

Example markup:

  & lt; Asp: list view id = "myListView" run = "server" OnItemCommand = "myListView_ItemCommand" ... />  

and behind this code:

  Protected myListView_ItemCommand (Object Sender, ListViewCommandEventArgs E) {//e.CommandName gives the name of the name you specify  

There is an MSDN documentation on it.

Hope this can help you a bit.


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 -