更新面板中的按钮事件不是触发 [英] Button event within the update Panel is not Triggering

查看:67
本文介绍了更新面板中的按钮事件不是触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我在更新面板中创建了一个DropDownList按钮以显示Gridview,但是当我在下拉列表中选择项目时,我的网格视图不在更新面板中/单击按钮时未点击/索引更改事件显示网格视图?



这是我的设计:



Question : I Created a DropDownList, button within update Panel to display the Gridview,but my grid view is not in the update panel when is selecting the item in dropdown/clicking the button the click /index change event is not fired to display the Grid View?

This is my Design:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="probrand.aspx.cs" Inherits="probrand" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

     <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel runat="server" id="UpdatePanel" UpdateMode="Always" >
        <Triggers>
            <asp:AsyncPostBackTrigger controlid="Btn_Grid"/>
        </Triggers>
            <ContentTemplate>
            <div>
            <table>
            <tr>
            <td><asp:DropDownList ID="ddlitems"  runat="server" AutoPostBack="true" onselectedindexchanged="ddlitems_SelectedIndexChanged" CausesValidation="false"  ></asp:DropDownList></td>
            <td><asp:Button ID="Btn_Grid" runat="server" onclick="Btn_Grid_Click" Text="Grid" CausesValidation="false"  /></td>
            </tr>
            </table>
            </div>
            </ContentTemplate>
        </asp:UpdatePanel>
       <%--  <asp:ListItem Id="DL1" Text="Lee" runat="server">
        </asp:ListItem>
        <asp:ListItem Id="DL2" Text="Levis" runat="server">
        </asp:ListItem> --%>
        <%--</asp:DropDownList> --%>
        <asp:GridView ID="GRD" runat="server" AutoGenerateColumns="false">
        <Columns>
        <asp:TemplateField HeaderText="Product_ID">
        <ItemTemplate>
        <asp:Label ID="LblProductID" runat="server" Text='<%#Eval("P_id") %>'>
        </asp:Label>
        <asp:TextBox ID="txtProductID" runat="server" Text='<%#Bind("P_id") %>' Visible="false">
        </asp:TextBox>


        </ItemTemplate>
        </asp:TemplateField>

         <asp:TemplateField HeaderText="Product_Name">
        <ItemTemplate>
        <asp:Label ID="LblProductName" runat="server" Text='<%#Bind("Product_Name") %>'>
        </asp:Label>
        <asp:TextBox ID="TxtProductName" runat="server" Text='<%#Bind("Product_Name")%>' Visible="false">
        </asp:TextBox>



        </ItemTemplate>
        </asp:TemplateField>

         <asp:TemplateField HeaderText="Price">
        <ItemTemplate>
        <asp:Label ID="LblPrice" runat="server" Text='<%#Bind("Price") %>'>
        </asp:Label>
        <asp:TextBox ID="TxtPrice" runat="server" Text='<%#Bind("Price") %>' Visible="false">
        </asp:TextBox>

        </ItemTemplate>
        </asp:TemplateField>

         <asp:TemplateField HeaderText="Brand_Name">
        <ItemTemplate>
        <asp:Label ID="LblBrandName" runat="server" Text='<%#Bind("B_Name") %>'>
        </asp:Label>
        <asp:TextBox ID="TxtBrandName" runat="server" Text='<%# Bind("B_Name") %>' Visible="false">
        </asp:TextBox>


        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Edit">
        <ItemTemplate>
        <asp:Button ID="BtnEdit" runat="server" Text="Edit"  CommandArgument='<%# Bind("P_id") %>' OnCommand="Edit" />
        <asp:Button ID="BtnUpdate" runat="server" Text="Update" CommandArgument='<%# Bind("P_id") %>' OnCommand="Update" />
        <asp:Button ID="BtnCancel" runat="server" Text ="Cancel" CommandArgument='<%# Bind("P_id") %>' OnCommand="Cancel" />
       </ItemTemplate>
        </asp:TemplateField>


        </Columns>
   </asp:GridView>

    </div>
 </form>
</body>
</html>

推荐答案

这篇关于更新面板中的按钮事件不是触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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