Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I assign some data to a Label control 'LblDetails' in run time. I have a button id 'BtnDetails'.
The following code is not displaying the data contained in 'LblDetails'. I understand that on click of button 'BtnDetails' it is not going to 'eventDetails'. How to make everything fine so that I could see the data available in that 'LblDetails' seen through 'modal popup extender'.

XML
<asp:UpdatePanel ID="dd" runat="server"   >
   <ContentTemplate>
    <asp:Button ID="AddToCart"  runat = "server" Text='Add to Cart'   BackColor="DarkSlateBlue" Width="100px"  Style=" font-family:Arial" ForeColor="White" commandname="myevent">
    </asp:Button>
    <asp:Button ID="BtnDetails"  runat = "server" Text='Details'   BackColor="DarkSlateBlue" Width="100px"  Style=" font-family:Arial" ForeColor="White" commandname="myeventDetails">
    </asp:Button>
<asp:modalpopupextender id="ModalPopupExtender1" runat="server"
    cancelcontrolid="btnCancel" okcontrolid="btnOkay"
    targetcontrolid="BtnDetails" popupcontrolid="Lbldetails"
    popupdraghandlecontrolid="PopupHeader" drag="true"
    backgroundcssclass="ModalPopupBG">
</asp:modalpopupextender>
<asp:Label id="Lbldetails" style="display: none" runat="server">
    <div class="HellowWorldPopup">
    <div class="PopupHeader" id="PopupHeader">Header</div>
    <div class="PopupBody">
    <p>This is a simple modal dialog</p>
    </div>
    <div class="Controls">
    <input id="btnOkay" type="button" value="Done" />
   <input id="btnCancel" type="button" value="Cancel" />
        </div>
        </div>
   </asp:Label>
    </ContentTemplate>
    </asp:UpdatePanel>



C#
 if (e.CommandName == "myeventDetails") // check commandname here
        {
            int index = e.Item.ItemIndex;
            Label lbl1 = (Label)DataList1.Items[index].FindControl("lblProductId");
            v_code = Convert.ToInt32(lbl1.Text);
            Label CategoryLbl = (Label)DataList1.Items[index].FindControl("CategoryLbl");
            v_categoryid = Convert.ToInt32(CategoryLbl.Text);
            SqlCommand cmd4 = new SqlCommand("SELECT DescriptionStatic from product WHERE CategoryId='" + v_categoryid + "' and ProductId='" + v_code + "'", con);
        SqlParameter param4 = new SqlParameter();
        param4.ParameterName = "@v_mem_id1";
        param4.Value = "ss";
        cmd4.Parameters.Add(param4);
        con.Open();
        SqlDataReader reader1 = cmd4.ExecuteReader();
        if (reader1.HasRows)
        {
            while (reader1.Read())
            {
                string v_descriptionstatic = reader1.GetString(0);
                Lbldetails.Text = v_descriptionstatic;
}
}
}
Posted
Updated 20-Feb-14 23:54pm
v2
Comments
Charan_Kumar 24-Feb-14 4:05am    
try to use session for storing data...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900