I have been tasked with updating an ASP web Application to Visual Studio 2015. I have a Master page that looks like this:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="HorizontalMenu.master.cs" Inherits="HomiLog2015.HorizontalMenu" %>
<%# Register Src="~/Header and Footer/Footer.ascx" TagPrefix="uc1" TagName="Footer" %>
<%# Register Src="~/Header and Footer/Header.ascx" TagPrefix="uc1" TagName="Header" %>
<%# Register Src="~/Menu.ascx" TagPrefix="uc1" TagName="Menu" %>
<link href="App_Themes/Rockies/BaseStyles.css" rel="stylesheet" />
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body id="Body1" runat="server">
<form runat="server" id="form1" method="post">
<asp:ScriptManager ID="scriptManager1" runat="server" EnablePartialRendering="True" EnablePageMethods="True" EnableScriptGlobalization="True" EnableScriptLocalization="True">
</asp:ScriptManager>
<table border="0">
<tr>
<td class="pcT" colspan="2">
<uc1:Header runat="server" ID="Header1" />
</td>
<td class="pcTR"></td>
</tr>
<tr>
<td class="pcml"></td>
<td class="MLMmc">
<uc1:Menu runat="server" id="Menu1" />
</td>
</tr>
<tr>
<td class="pcL"></td>
<td class="pcC">
<asp:ContentPlaceHolder id="PageContent" runat="server"/>
</td>
<td class="pcR"></td>
</tr>
<tr>
<td class="pcBL"></td>
<td class="pcB">
<uc1:Footer runat="server" ID="Footer1" />
</td>
<td class="pcBR"></td>
</tr>
</table>
</form>
</body>
</html>
I Have an ASP web page with a GridView and need to Edit, Delete, and Insert records. I have gotten the edit and delete functions running but am having a problem with the Insert portion.
When I attempt to save the new record all of the data fields are empty. I know the C# code is reading the text values on the row because I have a dropdown and a checkbox on the rows that are getting their values, but it is the default values and not the ones I selected for the insert.
Pretty sure it is a post back problem since I have noticed I don't have an UpdatePanel on my web page. I have tried to wrap the gridview within an UpdatePanel but when I do that I get the error stating GridView is not a known element. I have tried wrapping the gridview in a Div and then wrapping the div in the update panel. But then I get the Error div cannot be nested in the update panel.
So I think I need to include the update panel on the Master page but cannot get it to compile when I move it over there. I have tried putting the panel in various location on the Master Page. Can someone point me in the right direction on this?
I have been asked to provide more code here is the ASPX page that has the gridview
<%# Page Title="" Language="C#" MasterPageFile="~/HorizontalMenu.Master"
AutoEventWireup="true" CodeBehind="EditMembers.aspx.cs"
Inherits="HomiLog2015.EditMembers" %>
<%# Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI"
TagPrefix="telerik" %>
<asp:Content ID="Content2" ContentPlaceHolderID="PageContent"
runat="server">
<section id="searchHeader" class="Search">
<p class="searchp">Members</p>
</section>
<section id="SearchArea" class="SearchBar">
Search for:
<br />
<br />
Last Name:
</section>
<section id="searchFooter" class="Search">
<p>*</p>
</section>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
Skin="Default"></telerik:RadAjaxLoadingPanel>
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
<section id="grid" class="Grid-Container">
<p style="text-align: Left;">
<asp:Button ID="btnAdd" runat="Server" Text="Add New Record"
OnClick="btnAdd_Click" /></p>
<asp:GridView ID="MembersGridView" runat="server" EnableViewState="true"
DataKeyNames="UserId"
AutoGenerateColumns="false"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="false"
OnRowDataBound="MembersGridView_RowDataBound"
OnRowEditing="MembersGridView_RowEditing"
OnRowCancelingEdit="MembersGridView_RowCancelingEdit"
OnRowUpdating="MembersGridView_RowUpdating"
OnRowUpdated="MembersGridView_RowUpdated"
OnRowDeleting="MembersGridView_RowDeleting"
OnRowCommand="MembersGridView_RowCommand"
OnSorting="MembersGridView_Sorting"
AllowPaging="true"
AllowSorting="true"
EmptyDataText="No Data Has Been Entered"
HorizontalAlign="Left"
ShowFooter="false"
OnPageIndexChanging="MembersGridView_PageIndexChanging"
BackColor="White" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat="server" ID="MembersDeleteButton"
CommandArgument='<%#Eval("username")%>'
OnClientClick="return confirm('Are you sure you want
to delete this event?');"
OnCommand="DeleteMember" Text="Delete"
ImageUrl="../Images/Icon_delete.gif">
</asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Valid" ItemStyle-Width="10">
<ItemTemplate>
<asp:CheckBox ID="chkActive" runat="server" Checked='<%#
Eval("valid")%>' Enabled="false"></asp:CheckBox>
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="chkActive" runat="server" Checked='<%#
Eval("valid")%>'></asp:CheckBox>
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="chkActive" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name" ItemStyle-
Width="100">
<ItemTemplate>
<asp:Label ID="lblFirstName" runat="server" Text='<%#
Eval("firstname")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFirstName" runat="server" Text='<%#
Eval("firstname")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtFirstName" Text="Hello"
runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblLastName" runat="server" Text='<%#
Eval("Lastname")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLastName" runat="server" Text='<%#
Eval("Lastname")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLastName" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="User Name" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblUsertName" runat="server" Text='<%#
Eval("username")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUserName" runat="server" Text='<%#
Eval("username")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtUserName" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Role" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%#
Eval("role")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlRole" runat="server"
DataTextField="Role1" DataValueField="RoleID"></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlRole" runat="server"
DataTextField="Role1" DataValueField="RoleID"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblEmail" runat="server" Text='<%#
Eval("EmailAddress")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtemail" runat="server" Text='<%#
Eval("EmailAddress")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:Button ID="btnInsert" runat="Server" Text="Insert"
CommandName="Insert" UseSubmitBehavior="False" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="Numeric"
Position="Bottom"
PageButtonCount="10" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999"
Height="30px"
VerticalAlign="Bottom"
HorizontalAlign="center" ForeColor="Black" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True"
ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<EmptyDataTemplate>
<asp:CheckBox ID="chkActive" runat="server" Checked='<%#
Eval("valid")%>' Enabled="false"></asp:CheckBox>
<asp:Label ID="lblFirstName" runat="server" Text='<%#
Eval("firstname")%>'></asp:Label>
<asp:Label ID="lblLastName" runat="server" Text='<%#
Eval("Lastname")%>'></asp:Label>
<asp:Label ID="lblUsertName" runat="server" Text='<%#
Eval("username")%>'></asp:Label>
<asp:DropDownList ID="ddlRole" runat="server"
DataTextField="Role1" DataValueField="RoleID"></asp:DropDownList>
<asp:Label ID="lblEmail" runat="server" Text='<%#
Eval("EmailAddress")%>'></asp:Label>
</EmptyDataTemplate>
</asp:GridView>
</section>
</asp:Content>
I have tried putting the update panel in various locations on this page but it will not compile.
Master pages are for styling. You should not be touching them in this case.
Add the MasterPageFile attribute to the Page element in your .aspx markup file that contains your GridView.
<%# Page MasterPageFile="~/YOUR_MASTER_PAGE_FILE" ... %>
Note the id of the asp:ContentPlaceHolder in your Master page.
<asp:ContentPlaceHolder id="PageContent" runat="server"/>
Wrap the content of your new .aspx page in a asp:Content element which has an attribute asp:ContentPlaceHolderID equal to the ID of the asp:ContentPlaceHolder element in your master page file.
<asp:Content ID="mainPlaceHolder" ContentPlaceHolderID="PageContent" runat="server">
Here is an example for inserting records using a GridView
Please post the relevant markup and back-end code for you GridView and insert logic. I can't offer any more assistance based on the information provided.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a GridView in which I have textboxes with calendar extendar. I am facing a strange problem.. The calendar extender works ok for the first row of the GridView but it does not work.
ASPX CODE is as below:(sorry, I know it's a long code.)
<asp:TabContainer AutoPostBack="false" ID="TabContainer_Main" Height="270px" runat="server">
<asp:TabPanel ID="TabPanel__TravelLine" runat="server" HeaderText="Travel Line">
<ContentTemplate>
<div id="div_TravelLine">
<asp:UpdatePanel ID="upPanel_TravelLine" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel_TravelLine" runat="server">
<asp:GridView ID="grvTravelLine" CssClass="tabledata" runat="server" ShowFooter="True"
AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" Width="100%" OnRowDataBound="grvTravelLine_RowDataBound">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="From City">
<ItemTemplate>
<asp:TextBox MaxLength="50" Text='<%# Eval("From_City") %>' onkeypress="return Alpha(event);"
ID="txtFrmCity_TravelLine" Width="70px" CssClass="txtbox" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="To City">
<ItemTemplate>
<asp:TextBox ID="txtToCity_TravelLine" Text='<%# Eval("To_City") %>' onkeypress="return Alpha(event);"
MaxLength="50" Width="70px" CssClass="txtbox" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Travel Mode">
<ItemTemplate>
<asp:DropDownList ID="ddlTravelMode_TravelLine" Width="100px" CssClass="drpdown"
runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Travel Date">
<ItemTemplate>
<asp:TextBox ID="txtTravelDt_TravelLine" Text='<%# Eval("TravelDt") %>' Width="70px"
runat="server" ClientIDMode="Static" CssClass="FormText"></asp:TextBox>
<asp:CalendarExtender
ID="Cal_txtTravelDt" CssClass="MyCalendar" runat="server" Format="yyyy/MM/dd"
TargetControlID="txtTravelDt_TravelLine">
</asp:CalendarExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Booking Date">
<ItemTemplate>
<asp:TextBox ID="txtBookingDt_TravelLine" Text='<%# Eval("BookingDt") %>' runat="server"
ClientIDMode="Static" CssClass="FormText"></asp:TextBox><asp:CalendarExtender ID="Cal_txtBookingDt"
CssClass="MyCalendar" runat="server" Format="yyyy/MM/dd" TargetControlID="txtBookingDt_TravelLine">
</asp:CalendarExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Arrival Date">
<ItemTemplate>
<asp:TextBox ID="txtArrivalDt_TravelLine" Text='<%# Eval("ArrivalDt") %>' runat="server"
ClientIDMode="Static" CssClass="FormText"></asp:TextBox><asp:CalendarExtender ID="Cal_txtArrivalDt"
CssClass="MyCalendar" runat="server" Format="yyyy/MM/dd" TargetControlID="txtArrivalDt_TravelLine">
</asp:CalendarExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:TextBox ID="txtAmount_TravelLine" AutoPostBack="true" OnTextChanged="txtAmount_TravelLine_OnTextChanged"
Text='<%# Eval("Amount") %>' MaxLength="7" Width="200px" onblur="Fixed(this);"
CssClass="txtbox" runat="server"></asp:TextBox><asp:FilteredTextBoxExtender ID="ftbetxtAmount_TravelLine"
runat="server" TargetControlID="txtAmount_TravelLine" FilterMode="ValidChars"
FilterType="Custom" ValidChars="0123456789.">
</asp:FilteredTextBoxExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="D">
<ItemTemplate>
<asp:LinkButton ID="lnkDel" runat="server" OnCommand="DeleteRowHandler_TravelLine"
Text="D"></asp:LinkButton></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<table width="100%">
<tr>
<td align="left">
<asp:LinkButton ID="LnkAddTravelLineToGrv" runat="server" Font-Bold="True" ForeColor="#3366FF"
OnClick="LnkAddTravelLineToGrv_Click">Click To Add</asp:LinkButton><b>
(Note: D = Delete) </b>
</td>
<td align="right">
<b>Grand Total: </b>
<asp:TextBox ID="txtgrandtotal" Style="text-align: right;" runat="server" ClientIDMode="Static"
CssClass="FormText" Width="80px"></asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="LnkAddTravelLineToGrv" />
</Triggers>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel_LodgingNLiving" runat="server" HeaderText="Lodging & living">
<ContentTemplate>
<div id="div_LodgingNLiving">
<asp:UpdatePanel ID="UpPanel_LodgingNLiving" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkAddLodgingLivingToGrv" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="Panel_LodgingLiving" runat="server">
<asp:GridView ID="grvLodgingLiving" OnRowDataBound="grvLodgingLiving_RowDataBound"
CssClass="tabledata" runat="server" ShowFooter="True" AutoGenerateColumns="False"
ShowHeaderWhenEmpty="True" Width="100%">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:TextBox MaxLength="50" Text='<%# Eval("City") %>' onkeypress="return Alpha(event);"
ID="txtCity_LodgingNLiving" Width="80px" CssClass="txtbox" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Lodging Nights">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("Lodging_Nights") %>' ID="txtLodgingNights_LodgingNLiving"
onkeypress="return OnlyNum(event);" Width="50px" MaxLength="3" CssClass="txtbox"
runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Lodging Days">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("Lodging_Days") %>' ID="txtLodgingDays_LodgingNLiving"
onkeypress="return OnlyNum(event);" Width="50px" MaxLength="3" CssClass="txtbox"
runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Hotel/Lodge Name">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("Hotel_LodgeName") %>' MaxLength="50" onkeypress="return Alpha(event);"
ID="txtHotelLodgename_LodgingNLiving" CssClass="txtbox" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Check-In Date">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("CheckInDt") %>' ID="txtCheckinDt_LodgingNLiving" runat="server"
ClientIDMode="Static" CssClass="FormText"></asp:TextBox><asp:CalendarExtender ID="Cal_txtCheckinDt_LodgingNLiving"
CssClass="MyCalendar" runat="server" Format="yyyy/MM/dd" TargetControlID="txtCheckinDt_LodgingNLiving" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Check-Out Date">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("CheckOutDt") %>' ID="txtCheckoutDt_LodgingNLiving" runat="server"
ClientIDMode="Static" CssClass="FormText"></asp:TextBox><asp:CalendarExtender ID="CaltxtCheckoutDt_LodgingNLiving"
CssClass="MyCalendar" runat="server" Format="yyyy/MM/dd" TargetControlID="txtCheckoutDt_LodgingNLiving" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remark">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("Remark") %>' CssClass="txtbox" ID="txtRemark_LodgingNLiving"
runat="server" Height="50px" Width="80px" MaxLength="100"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:TextBox Text='<%# Eval("Amount") %>' AutoPostBack="true" OnTextChanged="txtAmount_LodgingNLiving_OnTextChanged"
MaxLength="7" ID="txtAmount_LodgingNLiving" Width="70px" onblur="Fixed(this);"
CssClass="txtbox" runat="server"></asp:TextBox><asp:FilteredTextBoxExtender ID="Ftb_txtAmount_LodgingNLiving"
runat="server" TargetControlID="txtAmount_LodgingNLiving" FilterMode="ValidChars"
FilterType="Custom" ValidChars="0123456789.">
</asp:FilteredTextBoxExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="D">
<ItemTemplate>
<asp:LinkButton ID="lnkDel" runat="server" OnCommand="DeleteRowHandler_LodgingLiving"
Text="D"></asp:LinkButton></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<table width="100%">
<tr>
<td align="left">
<asp:LinkButton ID="lnkAddLodgingLivingToGrv" OnClick="LnkAddLodgingLivingToGrv_Click"
runat="server" Font-Bold="True" ForeColor="#3366FF">Click To Add</asp:LinkButton><b>
(Note: D = Delete) </b>
</td>
<td align="right">
<b>Grand Total: </b>
<asp:TextBox ID="txtGrandTotal_LodgingLiving" Style="text-align: right;" runat="server"
ClientIDMode="Static" CssClass="FormText" Width="80px"></asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel_IncidentalCost" runat="server" HeaderText="Incidental Cost">
<ContentTemplate>
<div id="div_IncidentalCost">
<asp:UpdatePanel ID="UpPanel_IncidentalCost" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LnkAddIncidentalCostToGrid" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="Panel_IncidentalCost" runat="server">
<asp:GridView ID="grvIncidentalCost" OnRowDataBound="grvIncidentalCost_RowDataBound"
CssClass="tabledata" runat="server" ShowFooter="True" AutoGenerateColumns="False"
ShowHeaderWhenEmpty="True" Width="100%">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Place">
<ItemTemplate>
<asp:TextBox MaxLength="50" Text='<%# Eval("Place") %>' onkeypress="return Alpha(event);"
ID="txtPlace_IncidentalCost" Width="200px" CssClass="txtbox" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:TextBox ID="txtAmount_IncidentalCost" MaxLength="7" Text='<%# Eval("Amount") %>'
Width="200px" onblur="Fixed(this);" CssClass="txtbox" runat="server"></asp:TextBox><asp:FilteredTextBoxExtender
ID="Ftb_txtAmount_IncidentalCost" runat="server" TargetControlID="txtAmount_IncidentalCost"
FilterMode="ValidChars" FilterType="Custom" ValidChars="0123456789.">
</asp:FilteredTextBoxExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remark">
<ItemTemplate>
<asp:TextBox CssClass="txtbox" AutoPostBack="true" OnTextChanged="txtRemark_IncidentalCost_OnTextChanged"
Text='<%# Eval("Remark") %>' ID="txtRemark_IncidentalCost" runat="server" Height="50px"
TextMode="MultiLine" Width="463px" MaxLength="100"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="D">
<ItemTemplate>
<asp:LinkButton ID="lnkDel" runat="server" OnCommand="DeleteRowHandler_IncidentalCost"
Text="D"></asp:LinkButton></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<table width="100%">
<tr>
<td align="left">
<asp:LinkButton ID="LnkAddIncidentalCostToGrid" runat="server"
Font-Bold="True" ForeColor="#3366FF"
OnClick="LnkAddIncidentalCostToGrid_Click">
Click To Add</asp:LinkButton>
<b>
(Note: D = Delete) </b>
</td>
<td align="right">
<b>Grand Total: </b>
<asp:TextBox ID="txtGrandTotal_IncidentalCost"
Style="text-align: right;" runat="server"
ClientIDMode="Static" CssClass="FormText" Width="80px"></asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
Problem is your ClientIDMode property on Textboxes
ClientIDMode="Static"
You need to remove abvoe attribute from your GridView code, because if you use it, all your TextBox controls will have the same ID, "txtCheckoutDt_LodgingNLiving" for this particular control on it calender extender is set. The CalendarExtender controls will find the first value (which is on the first row) and will be all mapped to it.
If you want to refine the patterns of your control ID assignment, here's more about the topic.
I have problem in nested update panel. I binding the gridview by using user control and my listbox is in the child update panel while selecting the items in listbox the page is getting refresh. but I don't want to get refresh.
Here is my aspx:
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SearchModule._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<link type="text/css" rel="stylesheet" href="Defaultstylesheet.css" />
<script src=<%--"Scripts/jquery-1.8.2.js" type="text/javascript"> </script> --%>
<%# Register TagPrefix="inc" TagName="sPager" Src="~/UserControls/SearchPager.ascx" %>
<asp:UpdatePanel ID="upseachr" runat="server" >
<ContentTemplate>
<div style="height: 50px;"></div>
<div class="searchtextbx">
<asp:TextBox ID="searchtext" runat="server"></asp:TextBox>
<asp:Button ID="Search" OnClick="Search_Click" CssClass="searchbtn" Text="Search" height="32" runat="server"> </asp:Button>
</div>
<asp:UpdateProgress ID="updatesearchpro" AssociatedUpdatePanelID="upseachr" runat="server" >
<ProgressTemplate>
<center>
<asp:Panel ID="searchpanel" runat="server">
<img alt="Processing" src="Images/359.gif" />
<br />
<asp:Label ID="panlab" runat="server" Text="Processing..."></asp:Label>
</asp:Panel>
</center>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="updFilters" runat="server" >
<ContentTemplate>
<div class="resultpage" style="overflow-x: scroll;">
<table>
<tr>
<div class="listbox">
<asp:Label ID="headertext" runat="server" CssClass="labelresul" Font-Bold="true" Height="50" Text="Available Filter"></asp:Label>
<span style="padding-left:10px;font-weight:700;"> <asp:HiddenField runat="server" ID="hdCount" /><asp:Label ID="Total" runat="server" Height="50"></asp:Label></span><span style="padding-left:5px;font-weight:700;"><asp:Label runat="server" ID="match" Visible="false" Text="Matches"></asp:Label> <asp:Label ID="remainingcount" ForeColor="Red" Visible="false" runat="server"></asp:Label> <asp:Label ID="remaining" runat="server" ForeColor="Red" Text="Remaining" Visible="true"></asp:Label> </span>
</div>
</tr>
<tr>
<asp:ListView ID="ListView1" runat="server" OnItemDataBound="ListView1_ItemDataBound" EnableViewState="false">
<ItemTemplate>
<td>
<asp:Label ID="listheader" runat="server" Text='<%# Eval("additional_info_name1") %>'></asp:Label>
<asp:ListBox ID="results" Width="200" Visible="true" runat="server" SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="results_SelectedIndexChanged" ></asp:ListBox>
</td>
</ItemTemplate>
</asp:ListView>
</tr>
<tr>
<td class="listbox1">
<asp:Button ID="btn" runat="server" Font-Size="12" Font-Bold="true" CssClass="searchbtn" OnClick="btn_Click" Text="Apply Filter" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div style="height: 40px;"></div>
<div class="resultpage" style="overflow-y: scroll;">
<asp:UpdatePanel ID="updPager" runat="server">
<ContentTemplate>
<inc:sPager ID="sPager" runat="server" OnPageIndexChanging="sPager_OnPageIndexChanging"></inc:sPager>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="updGrid" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" ItemStyle-VerticalAlign="Middle" AllowSorting="true"
ItemStyle-HorizontalAlign="Center" GridLines="None" CellSpacing="10" CellPadding="2" AllowCustomPaging="true" OnSorting="gvResults_Sorting"
AllowPaging="True" PageSize="20" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-CssClass="GridHeader" RowStyle-HorizontalAlign="Left" CssClass="GridStyle" >
<Columns >
<asp:TemplateField HeaderText="Stock Code" SortExpression="manufacturer_part_number" >
<ItemTemplate>
<asp:Label ID="lblFirstName" Text='<%# DataBinder.Eval(Container.DataItem, "manufacturer_part_number")%>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Manufacturer" SortExpression="Manufacturer" HeaderText="Manufacturer"></asp:BoundField>
<asp:BoundField DataField="Description" SortExpression="Description" HeaderText="Description"></asp:BoundField>
<asp:BoundField DataField="Availability" SortExpression="Availability" HeaderText="Availability"></asp:BoundField>
<asp:BoundField DataField="flag_rohs" SortExpression="flag_rohs" HeaderText="RoHS"></asp:BoundField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
It appears that your top-level UpdatePanel has an UpdateModeof Always (which is the default).
The MSDN documentation states:
If the UpdateMode property is set to Always, the UpdatePanel
control's content is updated on every postback that originates from
anywhere on the page. This includes asynchronous postbacks from
controls that are inside other UpdatePanel controls and postbacks
from controls that are not inside UpdatePanel controls.
You can rectify this by changing your top-level UpdatePanel control to conditional. e.g:
<asp:UpdatePanel ID="upseachr" runat="server" UpdateMode="Conditional">
Cheers
I have a UserControl which is a nested GridView (facebook like wall), i want to load posts on scrolling down. I am following this article..
CLICK ME
The problem is that this method is using the first column's last row to get the last productid
something like this
var lastProductId = $("#GridViewUserScraps tr:last").children("td:first").html();
But in my case i am not displaying any id in any of the columns of the UserControl's GridView though i have a ScrapId column(primary key) in database. How can i load Posts on scrolling down? how can i make it work?
My UserControl:
<div id="divProducts" style="height:700px;overflow:auto">
<asp:GridView ID="GridViewUserScraps" ItemStyle-VerticalAlign="Top" AutoGenerateColumns="False"
GridLines="None" Width="100%" ShowHeader="False" runat="server" AlternatingRowStyle-BackColor="#A5A5A5"
CellPadding="4" ForeColor="#333333" DataKeyNames="ScrapId" OnRowCommand="GridViewRowCommand">
<Columns>
<asp:TemplateField>
<FooterTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">Load More</asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
<table align="left" cellpadding="1" cellspacing="2">
<tr>
<td>
<a href='<%#getUserHREF(Container.DataItem)%>'>
<img align="middle" src='<%#getSRC(Container.DataItem)%>' border="0" width="50px" /></a>
</td>
<td>
</td>
</tr>
</table>
<div align="justify">
<b>
<%#DataBinder.Eval(Container.DataItem,"firstname")%>
<div>
<asp:HiddenField ID="hiddenLastProductID" runat="server" Value='<%# Eval("id") %>' />
</div>
</b>
<br />
<%#DataBinder.Eval(Container.DataItem, "Message")%>
<br />
<asp:Image ID="Image" runat="server" ImageUrl='<%# Eval("url") %>' style="max-width:500px;" />
</div>
<span class="SmallBlackText">Posted On: </span>
<asp:Label ID="lblSendDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"SendDate")%>'></asp:Label>
</span>
<br />
<%-- <asp:LinkButton ID="lnklike" runat="server"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
CommandName="LikeCmd">Like</asp:LinkButton>
<asp:LinkButton ID="lnkunlike" runat="server">unlike</asp:LinkButton>--%>
<asp:ImageButton ID="lnklike" runat="server" ImageUrl="~/Images/thumbsup.png" Height="20px"
Width="20px" CommandName="like" CommandArgument='<%# Eval("ScrapId")%>' />
<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnklike" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Controls_GetUserScraps.abc((int)Eval("ScrapId")) %>' />
</ContentTemplate>
</asp:UpdatePanel>
<%--<asp:Label ID="Label1" runat="server" Text='<%# WebPageName.StaticMethodName((int)Eval("ScrapId")) %>' />--%>
<asp:ImageButton ID="lnkunlike" runat="server" CommandArgument='<%# Eval("ScrapId")%>'
CommandName="unlike" Height="20px" ImageUrl="~/Images/thumbsdown.png" Width="20px" />
<asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkunlike" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Controls_GetUserScraps.xyz((int)Eval("ScrapId")) %>'></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:LinkButton ID="lnkcomment" runat="server">Comment</asp:LinkButton>
<asp:LinkButton ID="lnkviewall" runat="server" CommandName="viewall" CommandArgument='<%# Eval("ScrapId")%>'>View All</asp:LinkButton>
<br />
<asp:Panel ID="Pnlchildgrid" runat="server">
<asp:GridView ID="childgrid" runat="server" AutoGenerateColumns="False" OnRowCommand="childgrid_RowCommand"
Style="width: 450px; float: right;">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table align="left" cellpadding="1" cellspacing="2">
<tr>
<td>
<a href='<%#getUserHREF(Container.DataItem)%>'>
<img align="middle" src='<%#getSRC(Container.DataItem)%>' border="0" width="30px" /></a>
</td>
<td>
</td>
</tr>
</table>
<div align="justify">
<b>
<%#DataBinder.Eval(Container.DataItem, "firstname")%></b><br />
<%#DataBinder.Eval(Container.DataItem, "commentmsg")%>
<br />
</div>
<span class="SmallBlackText">Posted On: </span>
<asp:Label ID="lblSendDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"SendDate")%>'></asp:Label>
</span>
<br />
<asp:ImageButton ID="lnklike" runat="server" Height="20" Width="20" CommandName="childlike"
CommandArgument='<%# Eval("commentid")%>' ImageUrl="~/Images/thumbsup.png" />
<asp:Label ID="Label1" runat="server" Text='<%# Controls_GetUserScraps.abc1((int)Eval("commentid")) %>' />
<asp:ImageButton ID="lnkunlike" runat="server" CommandArgument='<%# Eval("commentid")%>'
CommandName="childunlike" Height="20" ImageUrl="~/Images/thumbsdown.png" Width="20" />
<asp:Label ID="Label2" runat="server" Text='<%# Controls_GetUserScraps.xyz1((int)Eval("commentid")) %>'></asp:Label>
<%-- <asp:LinkButton ID="lnkcomment" runat="server">Comment11111</asp:LinkButton>--%>
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Panel ID="Panel1" runat="server">
<asp:TextBox ID="txtcomment" runat="server" Width="500px" ></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Comment" CommandName="comment" CommandArgument='<%# Eval("ScrapId")%>' />
</asp:Panel>
</asp:Panel>
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<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" />
</asp:GridView>
</div>
I've got a search page that has the criteria in a panel, when the page opens obviously there are no results and the page footer is appearing directly beneath the search panel. How do I set the results panel to be a set height, then stretch to be the height of the grid when search results are found.
Cheers
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="FrmSearch.aspx.cs" Inherits="web.FrmSearch" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="pnlUpdate" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<div id="divSearch">
<asp:Panel ID="pnlSearch" runat="server" DefaultButton="BtnSearch">
<table width="100%">
<tr>
<td>
<asp:Label ID="LblName" runat="server" Text="Name:" CssClass="head2"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtSurname" runat="server" Width="200" CssClass="norm"></asp:TextBox>
</td>
<tr>
<td>
<asp:Label ID="LblAddress" runat="server" Text="Address:" CssClass="head2"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtAddress" runat="server" Width="200" CssClass="norm"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="BtnSearch" runat="server" Text="Search" OnClick="BtnSearch_Click" />
</td>
<td colspan="2" align="center">
<asp:Button ID="BtnReset" runat="server" Text="Reset" OnClick="BtnReset_Click" />
</td>
</tr>
</table>
</asp:Panel>
</div>
<div>
<asp:Label ID="lblCount" runat="server" CssClass="head2"></asp:Label>
</div>
<hr />
<div id="divResults">
<asp:Panel ID="pnlResults" runat="server">
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" Width="99%"
CssClass="grd" OnRowDataBound="gvResults_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:HiddenField ID="hfGUID" runat="server" Value='<%# Bind("GUID")%>' />
<asp:Label ID="LblName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="LblAddress" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Post Code">
<ItemTemplate>
<asp:Label ID="LblPostCode" runat="server" Text='<%# Bind("Post_Code") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Telephone">
<ItemStyle Width="150px" />
<ItemTemplate>
<asp:Label ID="LblTelephone" runat="server" Width="150px" Text='<%# Bind("Telephone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch" />
<asp:AsyncPostBackTrigger ControlID="btnReset" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
You can use min-height:200px to divSearch container.
#divSearch
{
min-height:200px //according to your requirement
}
This UpdatePanel is contained by an UserControl. When the LinkButton is pressed arow should be added in another GridView. When an user is logged in this control is working well.
The problems appears when an user is not logged in and try to push that button. No event triggers.
Someone suggested me to give a permission for accessing this control in web.config. That didn't work.
Anyone has another idea?
<asp:UpdatePanel runat="server" UpdateMode="Conditional" EnableViewState="true" ID="IngredientsUpdatePanel">
<ContentTemplate>
<asp:ObjectDataSource ID="sourceIngredients" runat="server" SelectMethod="GetAll">
</asp:ObjectDataSource>
<asp:GridView ID="Ingredients" AllowPaging="true" runat="server" DataKeyNames="IngredientId"
EnableViewState="true" DataSourceID="sourceIngredients" PageSize="5"
AutoGenerateColumns="false" HorizontalAlign="Center" OnSelectedIndexChanged="Ingredients_SelectedIndexChanged">
<RowStyle HorizontalAlign="Center" />
<HeaderStyle Font-Bold="true" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="Ingrediente" ItemStyle-Font-Size="10">
<ItemTemplate>
<asp:Label ID="lblId" Text='<%# Bind("IngredientId") %>' Visible="false" runat="server"/>
<asp:Label ID="lblPrice" Text='<%# Bind("Price") %>' Visible="false" runat="server"/>
<asp:Label ID="lblDescr" Text='<%# Bind("Description") %>' Visible="false" runat="server"/>
<asp:Label ID="lblName" Text='<%# Bind("Name") %>' Visible="false" runat="server"/>
<asp:Label ID="lblPict" Text='<%# Bind("Picture") %>' Visible="false" runat="server"/>
<div style="text-align:left;">
<img id="img" style="float:right;" src='<%# Eval("Picture") %>'
height="75" runat="server" alt="Picture" />
<b>
<%# Eval("Name") %>
</b>
<br />
<br />
Price: <b><%# Eval("Price") %></b>
<br />
<br />
<br />
</div>
<hr />
<div style="text-align:left;">
<b>Description</b>
</div>
<div style="width:300px;">
<%# Eval("Description") %>
</div>
<br />
<asp:LinkButton Enabled="true" runat="server" Text="Add" CommandName="Select" ID="cmdAdd" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
I solved the problem in a tricky way.
I deleted the LinkButton and before TemplateField I put a ButtonField and all is working fine.
Now the code looks like:
<Columns>
<asp:ButtonField Text="Add" CommandName="Select" />
<asp:TemplateField>
......
</asp:TemplateField>
</Columns>
Still I'm not understanding why the control had that behavior.
Don't forget to give the webresource.axd enough rights in the web.config?