如何在gridview按钮单击中查看更多图像 [英] how to view more images in gridview button click

查看:59
本文介绍了如何在gridview按钮单击中查看更多图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中使用gridview



i将绑定到gridveiw中的一个类别图像,图像包含5个图像



i是点击查看按钮,所有图像都显示在datalist中。



注意:



查看按钮包含在网格中



请帮助我任何身体

i have using in gridview in asp.net

i will bind to the one category images in gridveiw that images include 5 images

i was click view button that all images was display in datalist.

note:

that view button include in grid

pls help me any body

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

     AllowPaging="True"  PageSize="30" 

   CssClass="table" GridLines="None" onrowcommand="GridView1_RowCommand">               
    <columns>
    <asp:TemplateField HeaderText="ID" Visible="false">
    <itemtemplate>
    <asp:Label ID="lblid" runat="server" Text='<%#Eval ("product_id") %>' >
      <%-- <asp:Label ID="lbl_productoffer" runat="server" Text='<%#Eval ("product_offer") %>' >--%>
  <%--  <asp:Label ID="lbl_productofferprice" runat="server" Text='<%#Eval ("product_offerprice") %>' >--%>
    <asp:Label ID="lbl_product_image2" runat="server" Text='<%#Eval ("product_image2") %>' >
    <asp:Label ID="lbl_product_image3" runat="server" Text='<%#Eval ("product_image3") %>' >
    <asp:Label ID="lbl_product_image4" runat="server" Text='<%#Eval ("product_image4") %>' >
    <asp:Label ID="lbl_product_image5" runat="server" Text='<%#Eval ("product_image5") %>' >
    </itemtemplate>
    
    <asp:TemplateField HeaderText="S.No">
    <itemtemplate><%#Container.DataItemIndex+1 %> </itemtemplate>
    
    <asp:TemplateField HeaderText="Product Name">
    <itemtemplate>
    <asp:Label ID="lblname" runat="server" Text='<%#Eval ("product_name") %>'>
    </itemtemplate>        
    
    <asp:TemplateField HeaderText="Product Price">
    <itemtemplate>
     Rs   <asp:Label ID="lblprice" runat="server" Text='<%#Eval ("product_price") %>'>
    </itemtemplate>        
    
    <asp:TemplateField HeaderText="Product Image">
    <itemtemplate>
       <asp:Image ID="Image1" runat="server" ImageUrl='<%#  Eval("small_image") %>'    rel="lightbox[Brussels]" Height="100px" Width="100px" />
    <asp:Label ID="lblimage" runat="server" Text='<%#Eval ("product_image") %>' Visible="false">
    <asp:Label ID="lblimage2" runat="server" Text='<%#Eval ("small_image") %>' Visible="false">
    </itemtemplate>        
    
    <asp:TemplateField HeaderText="Subcategory Name">
    <itemtemplate>
    <asp:Label ID="lblsubcategoryname" runat="server" Text='<%#Eval ("subcat_name") %>'>
    </itemtemplate>        
    
    <asp:TemplateField HeaderText="Category Name">
    <itemtemplate>
    <asp:Label ID="lblcategoryname" runat="server" Text='<%#Eval ("category_name") %>'>
    </itemtemplate>        
    
   <%-- <asp:TemplateField HeaderText="Product Description" Visible="false">
    <itemtemplate>
    <asp:Label ID="lbldesc" runat="server" Text='<%#Eval ("product_description") %>'>
    </itemtemplate>        
    --%>
    <asp:TemplateField HeaderText="Veiw"  >
     <itemtemplate>
    <asp:Button ID="Veiw" runat="server"   class="btn  btn-primary "

        rel="lightbox[Brussels]"              OnClientClick="return confirm('Are you sure want to Edit?');" 

             Text="Veiw" CommandName="view"/>
   </itemtemplate>
   
        </columns>

推荐答案

GridView1_RowCommand 事件内,查看是否CommandName是否为view。



如果是,则查找图像并使其可见。

Inside the GridView1_RowCommand Event, see if the CommandName is "view" or not.

If it is true, then Find the Images and make them visible.
void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
    // If multiple buttons are used in a GridView control, use the
    // CommandName property to determine which button was clicked.
    if(e.CommandName=="view")
    {
        // Convert the row index stored in the CommandArgument
        // property to an Integer.
        int index = Convert.ToInt32(e.CommandArgument);
        
        // Retrieve the row that contains the button clicked 
        // by the user from the Rows collection.
        GridViewRow row = GridView1.Rows[index];

        Image image1 = (Image)row.FindControl("Image1");
        image1.Visible = true;
    
        // Do like this for other images too.....
    }
}


这篇关于如何在gridview按钮单击中查看更多图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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