I have a Gridview with UpdateProgress, UpdatePanel and Linkbutton in gridview row TemplateField. When I click the Linkbutton, the UpdateProgress should work, but not in my case.
Here's the code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="CustomerID"
onpageindexchanging="GridView1_PageIndexChanging" Width="500px"
onrowcommand="GridView1_RowCommand"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="Customer ID" />
<asp:BoundField DataField="CompanyName" HeaderText="Company" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:TemplateField>
<ItemTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel2" >
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/ajax-loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode= "Conditional" >
<ContentTemplate>
<asp:LinkButton ID="lbtnExecute" runat="server" CommandArgument="<%# ((System.Web.UI.WebControls.GridViewRow)(Container)).DataItemIndex + 1 %>"
CommandName="Execute">Execute</asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lbtnExecute" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
I tried removing the:
AssociatedUpdatePanelID="UpdatePanel2"
but UpdateProgress showed in all rows. I want it to show only on the row where I click the Linkbutton.
Can anyone help?
Related
I'm having a problem with a couple of dropdown boxes in my gridview losing their values upon postback.
Everything is within an update panel so I have tried to include into my code but this just throws an exception. See the below code, I have a child gridview within a larger one:
I am receiving the following exception when I go to load the gridview: A control with ID 'DropDownNote' could not be found for the trigger in UpdatePanel 'UpdateGV'.
I followed what was in this post: Control in UpdatePanel loses value
But now I'm getting the above exception, what am I missing here? Will solving this problem retain the values of the dropdowns after the postback?
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:GridView ID="GVAccounts" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333"
GridLines="Horizontal"
style="position: relative; margin-top: 10px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="branch" HeaderText="Branch"
SortExpression="branch" />
<asp:BoundField DataField="no" HeaderText="Account"
SortExpression="account" />
<asp:TemplateField HeaderText="Name" SortExpression="name">
<EditItemTemplate>
<asp:TextBox ID="TextName" runat="server" Text='<%# Eval("name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelName" runat="server" Text='<%# Eval("name") + " " + Eval("surname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="type" HeaderText="Type" SortExpression="type" />
<asp:BoundField DataField="sub" HeaderText="Sub" SortExpression="sub" />
<asp:BoundField DataField="TotalAmount" HeaderText="Hold"
SortExpression="TotalAmount" />
<asp:BoundField DataField="loc" HeaderText="LOC" DataFormatString="{0:C}" SortExpression="loc" />
<asp:BoundField DataField="locstatus" HeaderText="LOC status"
SortExpression="locstatus" />
<asp:BoundField DataField="HoldCalc" HeaderText="OD/EX Amt" SortExpression="HoldCalc" />
<asp:BoundField DataField="odtimes" HeaderText="#OD" SortExpression="odtimes" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="gridChild" style="display: inline; position: relative; left: 15px; overflow: auto">
<asp:UpdatePanel ID="UpdateGV" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false"
BorderStyle="Double" BorderColor="#5D7B9D" Width="80%">
<HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true"
oncheckedchanged="chkSelect_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="effective" HeaderText="Effective" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="desc_" HeaderText="Desc" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="code" HeaderText="TC" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="amount" HeaderText="Amount" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="tracer" HeaderText="Cheq #" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="empltype" HeaderText="Empl" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="balance" HeaderText="OD/EXT Amt" HeaderStyle-HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Note">
<ItemTemplate>
<asp:DropDownList ID="DropDownNote" runat="server"
onselectedindexchanged="DropDownNote_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem></asp:ListItem>
<asp:ListItem>MWC</asp:ListItem>
<asp:ListItem>CBM</asp:ListItem>
<asp:ListItem>Return</asp:ListItem>
<asp:ListItem>TSF</asp:ListItem>
<asp:ListItem>OK NO S/C</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Note1">
<ItemTemplate>
<asp:DropDownList ID="ddNote2" runat="server">
<asp:ListItem Selected="True">NSF</asp:ListItem>
<asp:ListItem>Funds Not Clear</asp:ListItem>
<asp:ListItem>Post Dated</asp:ListItem>
<asp:ListItem>Stale Dated</asp:ListItem>
<asp:ListItem>Stop Payment</asp:ListItem>
<asp:ListItem>Encoding Incorrect</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Branch">
<ItemTemplate>
<asp:DropDownList ID="ddBranch" runat="server" DataSourceID="BranchDataSource"
DataTextField="branch" DataValueField="branch">
</asp:DropDownList>
<asp:SqlDataSource ID="BranchDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ThirdPartyDataConnectionString %>"
SelectCommand="SELECT [branch] FROM [branch]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account">
<ItemTemplate>
<asp:TextBox ID="TextNo" runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type">
<ItemTemplate>
<asp:DropDownList ID="ddType" runat="server" DataSourceID="typeSource"
DataTextField="Type" DataValueField="Type">
</asp:DropDownList>
<asp:SqlDataSource ID="typeSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ThirdPartyDataConnectionString %>"
SelectCommand="SELECT [Type] FROM [DMDType]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub">
<ItemTemplate><asp:TextBox ID="TextSub" Width="25px" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownNote" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
I decided to go a different route with this, I added MaintainScrollPositionOnPostback="true" to the top line of the aspx, since the complaint from the client was that the page would go back to the top after every postback. I had originally used the UpdatePanel to remedy this but decided this would be a better option.
Now my only problem is getting the page to retain the values of the dropdown boxes after a postback which I will have to figure out how that can be done.
I have asp grid view and i created 4 columns(Id,Name,quantity,price) and a footer. i have bounded all the 4 columns from the database. in the footer template, i added a dropdown list item.
every thing is working fine but, the problem is in the footer templalte dropdownlist is added after all the 4 columns but i want to add the dropdown footer to the 2nd column(Name).
Please apologise for my english n Help me
I used the following code:
<asp:GridView ID="gv_page2" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" ForeColor="Black" GridLines="Vertical" ShowFooter="True">
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="Black" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<Columns>
<asp:BoundField DataField="PRO_ID" HeaderText="PRO_ID" />
<asp:BoundField DataField="NAME" HeaderText="NAME" ItemStyle-Width="100px"/>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate> <asp:TextBox runat="server" Width="100px"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="PRICE" ItemStyle-Width="80px"/>
<asp:BoundField HeaderText="TOTAL_PRICE"/>
<asp:TemplateField>
<FooterTempenter code herelate >
<asp:DropDownList ID="ftrDDL" runat="server" DataTextField="PRO_ID" AppendDataBoundItems="true" DataSourceID="" Width="130px" EnableViewState="true" >
<asp:ListItem Text="SELECT ONE" Value=""></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
you need to modify the template of second column
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" Text='<%# Databinder.Eval(Container.DataItem,"Name") %>'
runat="server" Width="100px"></asp:Label></ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ftrDDL" runat="server" DataTextField="PRO_ID" AppendDataBoundItems="true"
DataSourceID="" Width="130px" EnableViewState="true">
<asp:ListItem Text="SELECT ONE" Value=""></asp:ListItem>
</FooterTemplate>
</asp:TemplateField>
I have not tested the code but this should work .Let me know if it did not work
Is it required you add the drop down list in the footer?
I would suggest adding the drop down to the Name column. The footer will always load last.
Use template filed for Name
<asp:GridView ID="gv_page2" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black"
GridLines="Vertical" ShowFooter="True">
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="Black" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<Columns>
<asp:BoundField DataField="PRO_ID" HeaderText="PRO_ID" />
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ftrDDL" runat="server" DataTextField="PRO_ID" AppendDataBoundItems="true"
DataSourceID="" Width="130px" EnableViewState="true">
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Width="100px"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="PRICE" ItemStyle-Width="80px">
<ItemStyle Width="80px"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="TOTAL_PRICE" />
</Columns>
</asp:GridView>
<code>
<asp:Content ID="manageProfileContent" runat="server" ContentPlaceHolderID="mainContentPlaceHolder">
<div class="Menu">
<asp:Label ID="manageProfileTitle" runat="server" Text="Manage Profile" />
</div>
<br />
<asp:Panel ID="manageProfileMessagePanel" runat="server">
<asp:Label ID="manageProfileMessageLabel" runat="server" Font-Names="Sans-serif" Font-Size="Medium" Font-Bold="true" ForeColor="Red" Text="" />
</asp:Panel>
<br />
<asp:GridView ID="profileGridView" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" ForeColor="Black" GridLines="Vertical"
DataKeyNames="userid" DataSourceID="profileGridViewSqlDataSource">
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField DataField="userid" HeaderText="userid" ReadOnly="True"
SortExpression="userid" />
<asp:CheckBoxField DataField="administrator" HeaderText="administrator"
SortExpression="administrator" />
<asp:CheckBoxField DataField="policy_originator" HeaderText="policy_originator"
SortExpression="policy_originator" />
<asp:CheckBoxField DataField="policy_approver" HeaderText="policy_approver"
SortExpression="policy_approver" />
<asp:CheckBoxField DataField="employee" HeaderText="employee"
SortExpression="employee" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="profileGridViewSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:policymgmConnectionString %>"
SelectCommand="SELECT [userid], [administrator], [policy_originator], [policy_approver], [employee] FROM [tbl_profile]">
</asp:SqlDataSource>
</asp:Content>
</code>
Do not specify profileGridView.Datasource = datatable; profileGridView.DataBind(); when you have already specified datasourceid for the gridview. As the error clearly says, either remove datasourceid for the gridview or the lines profileGridView.Datasource = datatable; profileGridView.DataBind(); from your code!
I have an admin page where a user will select a document path and add that path to a certain column of a database. I am using a fileupload on the page where they can find the document and copy the path and then paste it into the details view. However, I want to skip this step and I want them to select a document and automatically make the path show up in the details view.
<asp:FileUpload ID="FileUpload1" runat="server" Visible="False" Width="384px" /><br />
<br />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<center> <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="ID" DataSourceID="SqlDataSource1" Height="128px" Width="544px" Visible="False" OnModeChanged="Button2_Click" CellPadding="4" ForeColor="#333333" GridLines="None" >
<Fields>
<asp:BoundField DataField="Order" HeaderText="Order" SortExpression="Order" />
<asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department"/>
<asp:BoundField DataField="DOC_Type" HeaderText="DOC_Type" SortExpression="DOC_Type" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
<asp:BoundField DataField="DOC" HeaderText="DOC" SortExpression="DOC" />
<asp:BoundField DataField="Active" HeaderText="Active" SortExpression="Active" />
<asp:BoundField DataField="Rev_Date" HeaderText="Rev_Date" SortExpression="Rev_Date" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID" Visible="False" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="#5D7B9D" BorderStyle="None" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#E2DED6" BorderStyle="None" Font-Bold="True" />
<RowStyle BackColor="#F7F6F3" BorderStyle="None" ForeColor="#333333" />
<FieldHeaderStyle BackColor="#E9ECF1" BorderStyle="None" Font-Bold="True" />
<EmptyDataRowStyle BorderStyle="None" />
<PagerStyle BackColor="#284775" BorderStyle="None" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" BorderStyle="None" Font-Bold="True" ForeColor="White" />
<InsertRowStyle BorderStyle="None" />
<EditRowStyle BackColor="#999999" BorderStyle="None" />
<AlternatingRowStyle BackColor="White" BorderStyle="None" ForeColor="#284775" />
</asp:DetailsView>
<br />
I need to get the fileupload1 into the DOC contenttemplate area so instead of showing an empty textbox it will show just a textbox it will show the fileupload
I'm not sure if this helps, but it is a start:
<asp:TemplateField HeaderText="DOC">
<InsertItemTemplate>
<asp:FileUpload ID="FileUploadDOC" runat="server" Width="384px" />
</InsertItemTemplate>
</asp:TemplateField>
In Codebehind you can set the doc-path in the following way:
Private Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles DetailsView1.ItemInserting
Dim FileUploadDOC As FileUpload = DirectCast(Me.DetailsView1.FindControl("FileUploadDOC"), FileUpload)
e.Values("DOC") = FileUploadDOC.PostedFile.FileName
End Sub
I am using a ModalPopupExtender within an updatePanel to show a detailView when a user selects a "Details" Button within a GridView.
The problem is that when the button is selected the popup is not being displayed. I have stepped through the code and the mdlPopup.Show() method is being executed but the popup does not "Show" Could someone perhaps help me out with what is happening?
Here is my Code:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetRequests"
TypeName="RequestDAL" SortParameterName="SortExpression"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSourceDetails" runat="server" SelectMethod="GetRequestsDetail"
OnSelecting="OdsDetail_Selecting" TypeName="RequestDAL"></asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="RequestID"
DataSourceID="ObjectDataSource1" EnableModelValidation="True" AllowSorting="True"
CellPadding="10" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="gv_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="DateSubmit" HeaderText="DateSubmit" SortExpression="DateSubmit" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="lName" />
<asp:BoundField DataField="FirstDate" HeaderText="Date" SortExpression="FirstDate" />
<asp:BoundField DataField="BeginTime" HeaderText="Begin Time" SortExpression="beginTime" />
<asp:BoundField DataField="EndTime" HeaderText="End Time" SortExpression="endTime" />
<asp:BoundField DataField="Lab" HeaderText="Lab" SortExpression="room" />
<asp:BoundField DataField="ClassName" HeaderText="Class" SortExpression="Class" />
<asp:BoundField DataField="Semester" HeaderText="Semester" SortExpression="term" />
<asp:BoundField DataField="RequestID" HeaderText="RequestID" SortExpression="id" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnDetails" runat="server" Text="Details" CommandName="Select" /></ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
<asp:Panel ID="pnlPopup" runat="server" Style="display: none" Width="500px">
<asp:UpdatePanel ID="updatePnlRequestDetail" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<Ajax:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
<asp:Label ID="lblRequestDetail" runat="server" Text="Request Detail" BackColor="LightBlue"
Width="95%"></asp:Label>
<asp:DetailsView ID="dvRequestDetail" DataSourceID="ObjectDataSourceDetails" runat="server"
DefaultMode="Edit" Width="95%" BackColor="White" Visible="false">
<Fields>
<asp:BoundField HeaderText="Id" DataField="RequestID" /></Fields>
</asp:DetailsView>
<asp:LinkButton runat="server" ID="btnClose" Text="Close" CausesValidation="false"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
protected void gv_SelectedIndexChanged(object sender, EventArgs e) {
//show the detail view to render
dvRequestDetail.Visible = true;
// force the databinding
dvRequestDetail.DataBind();
// update the detail panel
updatePnlRequestDetail.Update();
//show the popup
mdlPopup.Show();
}
protected void OdsDetail_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
try
{
e.InputParameters["id"] = Convert.ToString(this.GridView1.DataKeys[this.GridView1.SelectedIndex].Value);
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
This is all taken from a tutorial I found for using Modal Popup extenders with ObjectDataSources http://mattberseth.com/blog/2008/04/masterdetail_with_the_gridview.html
2 thing I whould do:
set your GridView as a AsyncPostBackTrigger for the popup UpdatePanel.
put the TargetControl and the ModalPopupExtender outside of the PopupControl Panel.
<asp:Panel ID="pnlPopup" runat="server" Style="display: none" Width="500px">
<asp:UpdatePanel ID="updatePnlRequestDetail" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1" />
</Triggers>
<ContentTemplate>
<asp:Label ID="lblRequestDetail" runat="server" Text="Request Detail" BackColor="LightBlue" Width="95%"></asp:Label>
<asp:DetailsView ID="dvRequestDetail" DataSourceID="ObjectDataSourceDetails" runat="server" DefaultMode="Edit" Width="95%" BackColor="White" Visible="false">
<Fields>
<asp:BoundField HeaderText="Id" DataField="RequestID" />
</Fields>
</asp:DetailsView>
<asp:LinkButton runat="server" ID="btnClose" Text="Close" CausesValidation="false"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<Ajax:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground" />