当前位置:编程学习 > C#/ASP.NET >>

gridview单击行任意位置事件! 单击行显示隐藏的panel

我想要做一个点击gridview行任意位置,显示gridview外面的一个panel,里面有删除和下载,可以让我们删除gridview里面的数据;类似下图效果
前台页面代码:
<div id="divChoose">
        <asp:Panel ID="pnlChosse" runat="server" Visible="false">
            <asp:Button ID="btnDowmLoad" runat="server" Text="下载" />
            <asp:Button ID="btnDelect" runat="server" Text="删除" />
        </asp:Panel>
        <asp:Panel ID="pnlSelect" runat="server">
            <asp:TextBox ID="txtSelect" runat="server"></asp:TextBox>
            <asp:Button ID="btnSelect" runat="server" Text="搜索" OnClick="btnSelect_Click" />
        </asp:Panel>
    </div>
    <div>
        <asp:GridView ID="gvPPTList" runat="server" AllowPaging="True" BackColor="White"
            AutoGenerateColumns="False" AllowSorting="True" DataKeyNames="ID" CssClass="datatable"
            OnDataBound="gvPPTList_DataBound" OnRowDataBound="gvPPTList_RowDataBound" OnRowCommand="gvPPTList_RowCommand"
            OnPageIndexChanging="gvPPTList_PageIndexChanging" OnRowDeleting="gvPPTList_RowDeleting">
            <Columns>
                <asp:TemplateField HeaderText="缩略图">
                    <ItemTemplate>
                        <asp:Image ID="imgFstJPG" runat="server" Width="96" Height="72" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="File_Org_Name" HeaderText="PPT原始文件名" SortExpression="File_Org_Name" />
                <asp:BoundField DataField="File_Name" HeaderText="标题" SortExpression="File_Name" />
                <asp:BoundField DataField="Author" HeaderText="作者" SortExpression="Author" />
                <asp:BoundField DataField="Create_Time" HeaderText="创建时间" SortExpression="Create_Time" />
                <asp:BoundField DataField="Author" HeaderText="大小" SortExpression="Author" />
                <asp:BoundField DataField="Copyright" HeaderText="版权信息" SortExpression="Copyright" />
                <asp:CommandField ShowDeleteButton="True" />
                <asp:Button runat="server" Text="Button" />
            </Columns></asp:GridView>

后台databound的代码:
 protected void gvPPTList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Button btnHiddenPostButton = e.Row.FindControl("btnHiddenPostButton") as Button;
            if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Footer)
            {
                //当鼠标停留时更改背景色            
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#8EC26F'");
                //当鼠标移开时还原背景色           
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                //e.Row.Attributes.Add("OnClick", showDelect);
                //Button btn = e.Row.FindControl("buttonid") as Button;
                //if (btn != null)
                //{
                //    e.Row.Attributes.Add("onclick", "document.getElementById('" + btn.ClientID + "').click();");
                //}
                //设置悬浮鼠标指针形状为"小手"             
                e.Row.Attributes["style"] = "Cursor:hand";
                e.Row.Cells[6].Visible = false;
            }
            if (e.Row.RowIndex != -1)
            {
                Image imgFstJPG = e.Row.Cells[5].FindControl("imgFstJPG") as Image;
                string fileName = Path.GetFileName(e.Row.Cells[6].Text);
                fileName = fileName.Substring(0, fileName.Length - fileName.Length);
                string fstJPGPath = "~/Destination/" + fileName + "/JPG/幻灯片1.jpg";
                imgFstJPG.ImageUrl = fstJPGPath;

            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string script = "return confirm('确认删除?');";

                TableCell cell = e.Row.Cells[0];
                foreach (Control control in cell.Controls)
                {
                    if (control is ImageButton && control.ID == "ibtnDelete")
                    {
                        ((ImageButton)control).Attributes.Add("onclick", script);
                    }
                }
            }
        }

谁能说一下怎么写
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,