How to show button on click of link button of gridview - asp.net

I have a grid view and inside that i have some link button. What I am trying to do is when i clicked on link-button then two more buttons which is outside of grid view should be shown.
I searched it on google and i found some solutions as well. I set command name of linkbutton and on RowCommand event i write below code. But still those buttons are not shown to me.
Can you please help me.....
Code of Gridview:
<asp:Panel ID="Panel1" runat="server">
<fieldset>
<legend>Action</legend>
<table border='0' align='center'>
<tr>
<td align="center">
<asp:Button ID="btnShow" runat="server" Text="Show" />
</td>
<td align="center">
<asp:Button ID="btnRefresh" runat="server" Text="Reset" />
</td>
<td align="center">
<asp:Button ID="btnexptocsv" runat="server" Text="Export To CSV" Enabled="False" />
</td>
<td align="center">
<asp:Button ID="btnexptoexcel" runat="server" Text="Export To Excel" Enabled="False" />
</td>
</tr>
</table>
</fieldset>
</asp:Panel>
<asp:UpdatePanel ID="updgrd" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<fieldset>
<legend>Complaint Count </legend>
<asp:GridView ID="grd_ComplaintCount" runat="server" AutoGenerateColumns="False"
CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Total Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalComplaint" CommandName="lnkTotal" Text='<%#Bind("TotalComplaint") %>'
CommandArgument="Total"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Open Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalOpenComplaint" CommandName="lnkOpen"
Text='<%#Bind("TotalOpen") %>' CommandArgument="Open"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Closed Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalCloseComplaint" CommandName="lnkClosed"
Text='<%#Bind("TotalClose") %>' CommandArgument="Closed"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Reassigned Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalReassignedComplaint" CommandName="lnkReassign"
Text='<%#Bind("TotalMemberReAssign") %>' CommandArgument="Reassigned"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Observation Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalObservationComplaint" CommandName="lnkObeservation"
Text='<%#Bind("TotalObservation") %>' CommandArgument="Observation"></asp:LinkButton>
</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>
</fieldset>
<fieldset>
<legend>
<asp:Label runat="server" ID="Legend_Remark"></asp:Label></legend>
<asp:GridView ID="grd_ComplaintDetails" runat="server" AutoGenerateColumns="False"
CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None"
AllowPaging="True" PageSize="20">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="MemberComplaintID" DataNavigateUrlFormatString="frmComplaintActionDetails.aspx?CID={0}"
DataTextField="MemberComplaintNo" HeaderText="Complaint No" />
<asp:BoundField DataField="MemberCode" HeaderText="Member Code" />
<asp:BoundField DataField="DepartmentName" HeaderText="Service Area" />
<asp:BoundField DataField="ComplaintName" HeaderText="Type Of Complaint" />
<asp:BoundField DataField="AutoEscalation" HeaderText="Auto Escalation" />
<asp:BoundField DataField="ManualEscalation" HeaderText="Manual Escalation" />
<asp:BoundField DataField="ComplaintDate" HeaderText="Complaint Date" />
<asp:BoundField DataField="LastActionTakenBy" HeaderText="Last Action TakenBy" />
<asp:BoundField DataField="LastActionDate" HeaderText="Last ActionDate" />
<asp:BoundField DataField="Severity" HeaderText="Severity" />
<asp:BoundField DataField="ComplaintAction" HeaderText="Complaint Action" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#507CD1" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
Code of Rowcommand event:
Protected Sub grd_ComplaintCount_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grd_ComplaintCount.RowCommand
ComplaintCount_Detail(e.CommandArgument)
If e.CommandName = "lnkTotal" Then
btnexptocsv.Enabled = True
btnexptoexcel.Enabled = True
ElseIf e.CommandName = "lnkOpen" Then
btnexptocsv.Enabled = True
btnexptoexcel.Enabled = True
ElseIf e.CommandName = "lnkClosed" Then
btnexptocsv.Enabled = True
btnexptoexcel.Enabled = True
ElseIf e.CommandName = "lnkReassign" Then
btnexptocsv.Enabled = True
btnexptoexcel.Enabled = True
ElseIf e.CommandName = "lnkObeservation" Then
btnexptocsv.Enabled = True
btnexptoexcel.Enabled = True
Else
btnexptoexcel.Enabled = False
btnexptocsv.Enabled = False
End If
End Sub
My Question :How to Show Buttons (which is outside of grid view) after Link Button Clicked
(which is inside of gridview)

Put your buttons inside the UpdatePanel

Related

CheckedChanged Event in a Gridview checkbox to update hidden labels

I have a gridview where the first column are check boxes, the next column is ID's. I have hidden labels on the page that need to get the current ID for any check boxes checked. The labels are specific, hlbl_pain1, hlbl_pain2, hlbl_pain3. It doenst matter which label gets which ID I just need each of the 3 hidden labels to be populated with ID's. Right now on CheckedChanged the 3 labels all update with the same value. I'm having issues looping. This is in VB.
Here's my grid:
<asp:GridView ID="gv_pain" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataSourceID="ds_grid_pain" ForeColor="Black" GridLines="Vertical" style="text-align: left; font-size: x-small; ">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="CheckBoxPain" runat="server" AutoPostBack="True" Checked="false" OnCheckedChanged="CheckBoxPain_CheckedChanged" />
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("DrugID")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DrugID" InsertVisible="False" SortExpression="DrugID">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("DrugID") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_DrugID" runat="server" Text='<%# Bind("DrugID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="NickName" HeaderText="NickName" SortExpression="NickName" ItemStyle-Width="150px">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="DrugName" HeaderText="DrugName" SortExpression="DrugName" ItemStyle-Width="500px">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Quan1" HeaderText="Quan1" SortExpression="Quan1">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Quan2" HeaderText="Quan2" SortExpression="Quan2">
<ItemStyle Wrap="False" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<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" />
</asp:GridView>
Here are my labels:
<asp:Label ID="hlbl_pain1" runat="server" Visible="true"></asp:Label>
<asp:Label ID="hlbl_pain2" runat="server" Visible="true"></asp:Label>
<asp:Label ID="hlbl_pain3" runat="server" Visible="true"></asp:Label>
Here's what I'm trying to do in my CheckedChanged in the codebehind:
Protected Sub CheckBoxPain_CheckedChanged(sender As Object, e As System.EventArgs)
Dim row As GridViewRow
For Each row In gv_pain.Rows
Dim cbPain As CheckBox = row.FindControl("CheckBoxPain")
If cbPain.Checked = True Then
Dim lblDrugID As Label = row.FindControl("lbl_DrugID")
hlbl_pain1.Text = lblDrugID.text
End If
Dim cbPain1 As CheckBox = row.FindControl("CheckBoxPain")
If cbPain1.Checked = True Then
Dim lblDrugID As Label = row.FindControl("lbl_DrugID")
hlbl_pain2.Text = lblDrugID.text
End If
Dim cbPain2 As CheckBox = row.FindControl("CheckBoxPain")
If cbPain2.Checked = True Then
Dim lblDrugID As Label = row.FindControl("lbl_DrugID")
hlbl_pain3.Text = lblDrugID.text
End If
Next
End Sub

Error when trying to retain updatepanel values

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.

Issue with gridview buttons and sqldatasource

I have a gridview with edit and delete buttons:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" style= "-moz-border-radius: 15px;border-radius: 15px;"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="AREA" DataMember="DefaultView"
ForeColor="#333333" Height="90%" Width="90%">
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="AREA" HeaderText="AREA" ReadOnly="True"
SortExpression="AREA" />
<asp:BoundField DataField="LIDER_USUARIO" HeaderText="LIDER_USUARIO"
SortExpression="LIDER_USUARIO" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="editButton" runat="server" CommandName="Edit"
ImageUrl="images/pencil1.png" Text="Edit" />
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="BtnUpdate" runat="server" CommandName="Update"
Text="Edit" />
<asp:Button ID="BtnCancel" runat="server" CommandName="Cancel"
Text="Cancel" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="deleteButton" runat="server" CommandName="Delete"
ImageUrl="images/DeleteRed1.png"
OnClientClick="return confirm('Are u sure?');" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And a sqldatasource:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DBUserInterfaceConnectionString %>"
DeleteCommand="DELETE FROM [TABLE] WHERE ...;"
SelectCommand="SELECT * FROM [TABLE]"
UpdateCommand="UPDATE TABLE SET ...;">
</asp:SqlDataSource>
If I link them using DatasourceID(gridview property DataSourceID="SqlDataSource1") both buttons work, but I try to do it using vb code behind they DON'T(when I press buttons nothing happens):
Protected Sub Page_Load(...
GridView1.DataSource = SqlDataSource1
GridView1.DataBind()
I need to make it using code behind. How to make them work?
Try using the DataSourceID property and point it to the ID of the data source, like this:
GridView1.DataSourceID = SqlDataSource1.ID
GridView1.DataBind()
You need to wrap them in If Not IsPostBack:
Protected Sub Page_Load(...
If Not IsPostBack Then
GridView1.DataSource = SqlDataSource1
GridView1.DataBind()
EndIf

Find a server side control inside a empty template of a grid view without row data bound event

I have a Grid view in which a text box is present in footer and edit template from where user can update data. i made a table inside a empty template of a grid and add a server side text box on it so that user can insert data in a grid if there is no record present inside a grid.
There is a server side button present out side the grid, on clicking of that button i m saving the data that user insert or update via grid. Now i am facing the problem to find out the control present inside the empty template of the grid while i m saving the data.
My code looks like as :
<asp:GridView ID="grwBrandInfo" runat="server" Width="100%" HeaderStyle-CssClass="gridheaderstyle"
GridLines="Vertical" AutoGenerateColumns="false" ShowFooter="True" BackColor="White"
OnRowCommand="grwBrandInfo_RowCommand" OnRowEditing="grwBrandInfo_RowEditing"
OnRowDeleting="grwBrandInfo_RowDeleting" OnRowUpdating="grwBrandInfo_RowUpdating"
OnRowDataBound="grwBrandInfo_RowDataBound" OnRowCancelingEdit="grwBrandInfo_RowCancelingEdit"
BorderStyle="None">
<Columns>
<asp:TemplateField HeaderText="Quarts">
<ItemTemplate>
<%#Eval("QUARTS")%>
<asp:HiddenField ID="hdnPERMIT_QUANTITY_ID" runat="server" Value='<%#Eval("PERMIT_QUANTITY_ID") %>' />
<asp:HiddenField ID="hdnQuarts" runat="server" />
</ItemTemplate>
<FooterTemplate>
<asp:HiddenField ID="hdnPERMIT_QUANTITY_ID" runat="server" Value='<%#Eval("PERMIT_QUANTITY_ID") %>' />
<asp:TextBox ID="txtFootQuarts" runat="server" CssClass="txtfields" MaxLength="4"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:HiddenField ID="hdnPERMIT_QUANTITY_ID" runat="server" Value='<%#Eval("PERMIT_QUANTITY_ID") %>' />
<asp:TextBox ID="txtEditQuarts" runat="server" EnableViewState="false" Text='<%#Eval("QUARTS")%>'
CssClass="txtfields" MaxLength="4"></asp:TextBox>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<FooterStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<FooterTemplate>
<asp:LinkButton ID="lbtnInsert" runat="server" Text="Insert" CssClass="hypfield"
CommandName="Insert" ValidationGroup="save"></asp:LinkButton>
</FooterTemplate>
<FooterStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" HeaderText="Action" ShowDeleteButton="true"
ValidationGroup="save">
<ItemStyle CssClass="hypfield" HorizontalAlign="Center" VerticalAlign="Top" />
<ControlStyle CssClass="hypfield" />
<HeaderStyle HorizontalAlign="Center" />
</asp:CommandField>
</Columns>
<EmptyDataTemplate>
<table border="1" cellpadding="5" cellspacing="0" width="100%">
<tr align="Left" bgcolor="#726E6D">
<td>
<b>
<asp:HiddenField ID="hdnPERMIT_QUANTITY_ID" runat="server" Value='0' />
<asp:Label ID="lblQuarts" runat="server" ForeColor="white" Text="Quarts" CssClass="lblfields"></asp:Label></b>
</td>
</tr>
<tr align="left" id="trEntryNotCompleted" runat="server" bgcolor="#FFFFEE">
<td>
<asp:TextBox ID="txtQuarts" runat="server" CssClass="txtfields5char" MaxLength="4"></asp:TextBox>
</td>
</tr>
</table>
</EmptyDataTemplate>
<FooterStyle BackColor="#CCCC99" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#6B696B" CssClass="gridheaderstyle" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:Button ID="btnSave" runat="server" Text="Save" ValidationGroup="save" OnClick="btnSave_Click" />
So the problem is that how did i find the value of txtQuarts present in the empty template when i am saving data
Dim txtId As String = CType(gridHelpDesk.Controls(0).Controls(0).FindControl("txtId"), TextBox).Text

Asp ModalPopupExtender not displaying detail view

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" />

Resources