如何在数据列表中单击按钮附近显示标签 [英] How to make a label visible near to the button clicked in datalist

查看:71
本文介绍了如何在数据列表中单击按钮附近显示标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有几行的数据列表,在数据列表的最后,我有Button'Btndetails'和Lable LblDetails'。重复列设置为3.每列都有按钮'Btndetails'。

点击此按钮我想向用户显示标签'LblDetails'。有用。但是标签

显示在用户必须滚动和阅读的数据列表的最后一列。我希望这个

标签显示在该按钮本身附近,在同一列上。该怎么办?



I have a datalist with several rows and at the end inside the datalist I have Button 'Btndetails' and a Lable LblDetails'. The repeat columns is set to 3. Each column has button 'Btndetails'.
On click of this button I want to show a Label 'LblDetails' to the user. It works. But the Label
is shown at the last column of the datalist for which the user has to scroll and read. I want this
Label to be shown near to that button itself, on the same column itself. How to do it?

<asp:DataList ID="DataList1" runat="server"   BackColor="White"   Width="220" BorderStyle="None"    BorderWidth="2" OnItemCommand="dl_item_command" RepeatColumns="3"   style=" border-top-style:groove; border-top-color:Lime; border-left-width:medium;"   RepeatDirection="Horizontal"  >
<asp:UpdatePanel ID="dd" runat="server"    >
<ContentTemplate>
 <asp:Button ID="AddToCart"  runat = "server" Text='Add to Cart'   BackColor="#cccccc" Width="100px"  Style=" font-family:Arial" ForeColor="#333333" 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:Label ID="Lbldetails" runat="server" Visible="false" Height="197" BackColor="Black"    ForeColor="GhostWhite" style=" size:auto; overflow:auto; position:absolute;   width:246px"> </asp:Label>




if (e.CommandName == "myeventDetails") // check commandname here
       {
           int index = e.Item.ItemIndex;
         //  Button dd = (Button)DataList1.Items[index].FindControl("BtnDetails");
           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.Style[HtmlTextWriterStyle.Top] = "610px";
               Lbldetails.Visible = true;

推荐答案

这篇关于如何在数据列表中单击按钮附近显示标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆