Click here to Skip to main content
15,886,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, I have a grid view populated from the database.
i populate it Programmatically i make 2 bound columns and one template field.
in the template field button image when clicked populate ajax model PopUp extender to edit the row .
how to populate the pop up from template field ?
how to connect the ajax model popup to the btn image in the template field i mean.
Posted

XML
//aspx code

//add your model popup css here

//your grid

<asp:GridView ID="grvLog" runat="server" CssClass="tableMain" AutoGenerateColumns="false">
     <Columns>
        <asp:BoundField DataField="LogTypeName" HeaderText="Log"/>
                <asp:BoundField DataField="Message" HeaderText="Message" />
            <asp:TemplateField HeaderText="Stack Trace" >
                       <ItemTemplate>
                            <asp:LinkButton ID="lnkStackTrace" runat="server" Text="Show Popup" CommandName="Display"></asp:LinkButton>
                       </ItemTemplate>
                </asp:TemplateField>
     </Columns>
</asp:GridView>


    <asp:button id="btnHidden" runat="server" text="Button" style="Display:none;"/>


//your extender
    <asp:ModalPopupExtender ID="ModalPopup" runat="server"
        OkControlID="btnOkay" TargetControlID="btnHidden" PopupControlID="DivTrace" PopupDragHandleControlID="PopupHeader"
        Drag="true" BackgroundCssClass="ModalPopupBG">
    </asp:ModalPopupExtender>





//code behind aspx.cs

    protected void grvLog_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Display")
            {
                GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
                //access the value of your control/ fetch the data from database and fill your pop control here like--
        textboxInPopup.Text = ((TextBox)row.FindControl("txtYourTextBox")).Text;
                ModalPopup.Show();
            }
        }
 
Share this answer
 

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