Click here to Skip to main content
16,017,833 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

XML
<%@ 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>
Posted
Updated 10-Jul-14 3:19am
v2
Comments
CHill60 10-Jul-14 9:07am    
Don't put your question into the title, it has been truncated so we don't know what your problem is. Use the Improve Question link (appears when you hover over your post) and put the full question into the post and choose a sensible title
D C P 25-Jul-14 0:50am    
Do you want to display gridview on Button Click..?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900