Modal popup with gridview row detail


R

roberta

Hi! I've show many example but I don't know how to apply solutions to my
code: I've a gridview with a list of records, I'd like using a detail
button, open an ajax modal popup with the detail (for update) of the row
selected

<asp:GridView ID="gvElencoAttivita" runat="server"
AutoGenerateColumns="False" DataKeyNames="Id"
onrowdatabound="gvElencoAttivita_RowDataBound"
ShowFooter="true" AllowSorting="True" CellPadding="8" GridLines="Vertical">
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-Width="30">
<ItemTemplate>
<asp:Button ID="btnCancella"
OnClick="btnCancellaAttivita_Click" IDRiga='<%# Eval("ID") %>'
runat="Server" CausesValidation="False" Text="Cancella" Width="60px"
OnClientClick="return confirm('Cancellare la riga selezionata?');" />

</ItemTemplate>
<ItemStyle Width="30px"></ItemStyle>
</asp:TemplateField>
<asp:BoundField DataField="DescrizioneAttivita"
HeaderText="Descrizione attività" SortExpression="DescrizioneAttivita"/>
<asp:TemplateField HeaderText="DateApp">
<ItemTemplate>
<asp:Label ID="lblDateApp" runat="server" Text='<%#
Eval("DateApp") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>

</Columns>

</asp:GridView>
 
Ad

Advertisements

G

Guest

Hi! I've show many example but I don't know how to apply solutions to my
code: I've a gridview with a list of records, I'd like using a detail
button, open an ajax modal popup with the detail (for update) of the row
selected

<asp:GridView ID="gvElencoAttivita" runat="server"
AutoGenerateColumns="False" DataKeyNames="Id"
onrowdatabound="gvElencoAttivita_RowDataBound"
ShowFooter="true" AllowSorting="True" CellPadding="8" GridLines="Vertical">
         <Columns>
             <asp:TemplateField HeaderText="" ItemStyle-Width="30">
                 <ItemTemplate>
                     <asp:Button ID="btnCancella"
OnClick="btnCancellaAttivita_Click" IDRiga='<%# Eval("ID") %>'
runat="Server" CausesValidation="False" Text="Cancella" Width="60px"
OnClientClick="return confirm('Cancellare la riga selezionata?');" />

                  </ItemTemplate>
             <ItemStyle Width="30px"></ItemStyle>
             </asp:TemplateField>
             <asp:BoundField DataField="DescrizioneAttivita"
HeaderText="Descrizione attività" SortExpression="DescrizioneAttivita"/>
             <asp:TemplateField HeaderText="DateApp">
                 <ItemTemplate>
                     <asp:Label ID="lblDateApp" runat="server" Text='<%#
Eval("DateApp") %>'></asp:Label>
                 </ItemTemplate>
             <ItemStyle Width="150px"></ItemStyle>
             </asp:TemplateField>

        </Columns>

     </asp:GridView>


You need to get the gridviewrow from the sender to get the datakey

For example

protected void LinkButton_Click(object sender, EventArgs e)
{
LinkButton MyLink = sender as LinkButton;
GridViewRow row = (GridViewRow)MyLink.NamingContainer;
int id = (int)this.PMAGrid.DataKeys[row.RowIndex].Value;
....
// show the modal popup
this.mdlPopup.Show();

where mdlPopup is a name of your ModalPopupExtender
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top