Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how can I get a value from a control in datalist

Posted on 2011-02-25
2
Medium Priority
?
273 Views
Last Modified: 2012-06-27
Hi experts

I have an image button in a datalist shows products repeatly,its databinded to a datatable .
I wish to get the product id and show the detail of the product in a modalpopup panel.
but I dont know how to get that id from databinding .

thanks


0
Comment
Question by:hukaka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Rahul Agarwal earned 2000 total points
ID: 34986057
Try the Code:

Aspx Page:

   <!-- Begin Category Listing -->
                                    <asp:datalist id="dlCategories" runat="server">
                                        <ItemTemplate>
                                            <P class="wht_14" style="MARGIN: 8px 18px 2px 0px" align="right"><b>
                                                   
                                                    <asp:LinkButton id="Linkbutton1" Runat="server" CommandArgument='<%# Container.DataItem("categoryID") %>' CommandName="Edit">
                                                        <%#Container.DataItem("CategoryName")%>
                                                    </asp:LinkButton></b>
                                                    </P>
                                            <!-- Begin Product Listing -->
                                            <asp:Panel id="PanelProd" runat="server" Visible="false">
                                                <asp:DataList ID="dlProd" Runat="server">
                                                    <ItemTemplate>
                                                        <P class="wht_11" style="MARGIN: 0px 26px 4px 0px" align="right">
                                                        <asp:Image ID="imgArrow" Runat="server" Visible="False" ImageUrl="/images/ico_arrowRight.gif"></asp:Image>
                                                        <asp:LinkButton id="linkButton2" Runat="server" OnClick="ProductDetailClicked" CommandArgument='<%# Container.DataItem("productsID") %>'>
                                                                <%#Container.DataItem("ProductName")%>
                                                            </asp:LinkButton></P>
                                                    </ItemTemplate>
                                                </asp:DataList>
                                               
                                            </asp:Panel>
                                            <!-- End Product Listing -->
                                        </ItemTemplate>
                                    </asp:datalist>
                                    <!-- End Category Listing -->

Code Page:

Public Sub ProductDetailClicked(ByVal sender As Object, ByVal e As EventArgs)

        PanelMainProducts.Visible = False
        PanelProduct.Visible = True
        myConnection = New SqlConnection(conString)
        myConnection.Open()

        mycommand = New SqlCommand("getSpecificProduct", myConnection)
        mycommand.CommandType = CommandType.StoredProcedure

        Dim objButton As LinkButton

        If Session("ProdID") = "" Then
            objButton = CType(sender, LinkButton)
            mycommand.Parameters.Add(New SqlParameter("@productsID", SqlDbType.Int))
            mycommand.Parameters("@productsID").Value = objButton.CommandArgument
        Else
            mycommand.Parameters.Add(New SqlParameter("@productsID", SqlDbType.Int))
            mycommand.Parameters("@productsID").Value = sender
        End If

        myReader = mycommand.ExecuteReader

        Me.Bind_Data(myReader)

        myConnection.Close()

        Dim imgArrow As System.web.UI.WebControls.Image
        Dim i As Integer

        Do While i < Me.dlCategories.Items.Count

            imgArrow = CType(Me.dlProd.Items(i).FindControl("imgArrow"), System.Web.UI.WebControls.Image)
            imgArrow.Visible = True
            i = i + 1
        Loop

    End Sub
0
 

Author Comment

by:hukaka
ID: 34986325
wow
thank you agarwalrahul
for writing so many code in midnight
will check it tomorrow

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question