Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1309
  • Last Modified:

DataList nested DataList.. How to get Item Command ?

Sample code
 
only E.x sample. I would like to nested item command work.

 <asp:DataList ID="DataList1" runat="server">
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Brands") %>'></asp:Label>
            <asp:DataList ID="DataList2" runat="server">
                <ItemTemplate>
                    <asp:Button ID="Button1" runat="server" Text="Button"  CommandName="bottonget" />
                </ItemTemplate>
            </asp:DataList>
        </ItemTemplate>
    </asp:DataList>

 Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand

        If e.CommandName = "bottonget" Then
            Label1.text = "Hello World"
        End If

    End Sub
0
Nagao
Asked:
Nagao
  • 4
  • 4
1 Solution
 
ruffoneCommented:
Try this

    <asp:DataList ID="DataList1" runat="server">
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Brands") %>'></asp:Label>
            <asp:DataList ID="DataList2" runat="server" OnItemCommand="DataList1_ItemCommand">
                <ItemTemplate>
                    <asp:Button ID="Button1" runat="server" Text="Button"  CommandName="bottonget" />
                </ItemTemplate>
            </asp:DataList>
        </ItemTemplate>
    </asp:DataList>
 
 
    Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
        If e.CommandName = "bottonget" Then
            Response.Write("Hello World")
        End If
 
    End Sub

Open in new window

0
 
NagaoAuthor Commented:
Please understand. This code does not work. I know normally work fine e.commandname = "bottoset ". Import is "Nested Datalist".  When nested Datalist does not work "e.commandname".
0
 
ruffoneCommented:
Please note
<asp:DataList ID="DataList2" runat="server" OnItemCommand="DataList1_ItemCommand">
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NagaoAuthor Commented:
Thank you ruffone: but i got a error DataList1_itemCommnad is does not member page.aspx. How to do?
I try to delete(after "") Protected sub ...()  "Handles" . but i got same error. please help me.
0
 
ruffoneCommented:
could you send the error that  you get
0
 
NagaoAuthor Commented:
Please understand bit difference my VBNET is Japanese version.

BC30456: 'DataList1_ItemCommand' is 'ASP.control_products_ascx' does not member.
0
 
NagaoAuthor Commented:
Mr. ruffone:  Sorry I miss take a spell.  It work fine. Thank you a lot.

0
 
ruffoneCommented:
It is difficult to help you if I don't understand the problem you are having, and right now I don't. The code I sent you should work
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now