Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best pattern for Parent/Children UI design?
Message
From
26/03/2009 17:31:31
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01391176
Message ID:
01391766
Views:
43
Oh yeaaahhhh!!!! That's what I'm talkin' about!

Works like a charm. Many thanks.

Ok, so now can you please help me learn the difference between the technique you just showed me (OnClick event on a LinkButton), vs. another suggestion I got from someone on StackOverFlow:

They suggested the LinkButton also, but showed using CommandName="Select" on the LinkButton and then assigning OnItemCommand="CustomerList_ItemCommand" on the ListView itsself to handle the Command.

Please tell me if I need to understand this technique, becuase from reading the help about the ListView control, it seems like there are several Commands that can be called. I just want to make sure I am learning the proper basics here.

So, I played around with the Command technique, and it did fire off an event, and I could capture the CommandName and test for "Select", but I could not figure out how to get the selected customer number out of the thing. Seems like the scope was the ListView container, and not the LinkButton. Is it correct to think about it that when you are using Commands, that the ListView is handling the event, where as the OnClick technique you showed has the LinkButton is handling the event? I don't know enough about it yet to know which way is best.

Here is how far I got with the Command techniquet, but never could figure out how to get the CustomerNumber out of the passed parameters to pass to the getdata method:
        protected void CustomerList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {

                if (e.Item.ItemType != ListViewItemType.DataItem)
                {
                    return;
                }
                var dataItem = e.Item as ListViewDataItem;
                if (dataItem == null)
                {
                    return;
                }
                var SelectedCustomer = dataItem.DataItem (?????); 

                CustomerIdHere=???

                this.lvOpenOrders.DataSource =  GetOpenOrdersByCustomer(CustomerIdHere);
                this.lvOpenOrders.DataBind();
            }
        }
>Edit the template for the list and make the company a LinkButton. Then store the CustomerNumber in the CommandArgument of it, ex:
>
>
><asp:LinkButton runat="server" Text='<%# Eval("CustomerName") %' CommandArgument='<%# Eval("CustomerNumber") %' OnClick="CustomerClick" /
>
>
>Then add code in the code-behind for the event, retrieve the CustomerNumber from the CommandArgument and update the display.
>
>ex.
>
>
>protected void CustomerClick(object sender, EventArgs e)
>{
>     LinkButton button = sender as LinkButton;
>
>     if (button != null)
>     {
>         string customerNumber = button.CommandArgument;
>         // Update display
>     }
>}
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform