Use Itemcommand in C# of a listview

Asked

Viewed 225 times

1

I’m working with a ListView in which it presents the items in a disorderly list and as links. Under the ListView has the "CREATE" button to insert a new item into ListView.

I managed to get that when I edit any item from list by clicking on link, the "CREATE" button Enabled = false, I did this using the ItemCommand of ListView like this one in the code below. The problem is that I wanted to not allow the user to edit another item when he is inserting a new one, some hint?

The "CREATE" button is outside the ListView.

protected void lvDiagnosticos_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    if (e.CommandName == "Edit")
    {
        criarDiagnostico.Enabled = false;
    }
    else
    {
        criarDiagnostico.Enabled = true;
    }
}
  • "Asp.net" is related to the question?

  • Yes, because the control used is a Listview and is part of ASP.NET, it is in this control that the SQL command is used

1 answer

1

I didn’t understand 100% the process of inserting a new item you are using, but apparently it seems to me that it would be enough that during this process you change the property LabelEdit for False. Anyway, I also suggest you take a look at the link below, which shows a custom control, which can give you more flexibility for what you are looking for.

In-place Editing of Listview subitems.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.