I have a datalist with repeat column=3. On click on any of the column I intend to display a panel.
It works only when the 3rd column is clicked. When 1st and 2nd column is clicked the panel is not displaying though everything goes fine at breakpoint. At the same time if the datalist has only 2 columns reteieved from the table and if I click the 2 column, the panel is visible and panel for 1st column is not visible though at breakpoint everything is fine. How to solve this?
<asp:DataList ID="DataList1" runat="server" BackColor="White" Width="220" BorderStyle="None" BorderWidth="2" OnItemCommand="dl_item_command" RepeatColumns="3"
<asp:UpdatePanel ID="dd" runat="server" UpdateMode="Conditional" >
<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:Panel ID="PanelLblDetails" runat="server" Visible="false" Height="200" Width="250" style=" margin-top:-220px; margin-left:195px; position:absolute; background-color:Red">
<asp:Label ID="Lbldetails" runat="server" Visible="false" Height="197" BackColor="ButtonShadow" ForeColor="GhostWhite" style=" position:absolute; margin-top:2px; margin-left:1px; width:246px"> </asp:Label>
</asp:Panel>
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 = Convert.ToString(v_descriptionstatic);
Lbldetails.Visible = true;
PanelLblDetails.Visible = true;
}