Hello mates i have a page View All Applicants.aspx with gridview and a link button
i want to redirect to page View Applicant Detail.aspx when i click on link button and i want to show data in gridview on View Applicant Detail.aspx page based on the previous page values.
here is the code for View All Applicants.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="View All Applicants.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div><center>
</center>
<center style="background-color: silver">
</center>
<center>
<strong><span style="font-size: 16pt">List of All Applicants</span></strong></center>
<center style="background-color: silver">
</center>
<center>
</center>
<center>
</center>
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True"
>
<Columns>
<asp:BoundField DataField="PersonName" HeaderText="PersonName" SortExpression="PersonName" />
<asp:BoundField DataField="DegreeName" HeaderText="DegreeName" SortExpression="DegreeName" />
<asp:BoundField DataField="InstituteName" HeaderText="InstituteName" SortExpression="InstituteName" />
<asp:BoundField DataField="ExperienceYears" HeaderText="ExperienceYears" SortExpression="ExperienceYears" />
<asp:BoundField DataField="OrganizationName" HeaderText="OrganizationName" SortExpression="OrganizationName" />
<asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
<asp:TemplateField HeaderText="Applicant Detail">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Cancel"
OnClick="LinkButton1_Click" Text="View"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString8 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString8.ProviderName %>" SelectCommand="SELECT Distinct PERSONALDETAIL.PersonName, DEGREE.DegreeName, INSTITUTE.InstituteName, EXPERIENCE.ExperienceYears, EXPERIENCE.OrganizationName, EXPERIENCE.Designation FROM EXPERIENCE, EXPERIENCE EXPERIENCE_1, PERSONALDETAIL, DEGREE, INSTITUTE WHERE EXPERIENCE.ExperienceID = EXPERIENCE_1.ExperienceID">
</asp:SqlDataSource>
</center>
<center>
</center>
<center>
</center>
<center style="background-color: silver">
</center>
</div>
</form>
</body>
</html>
and for View Applicant Detail.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="View Applicant Detail.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div><center>
</center>
<center style="background-color: silver">
</center>
<center>
<strong><span style="font-size: 16pt">Job Applicant Detail</span></strong></center>
<center style="background-color: silver">
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ResumeID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ResumeID" HeaderText="ResumeID" InsertVisible="False"
ReadOnly="True" SortExpression="ResumeID" />
<asp:BoundField DataField="TotalExperienceYears" HeaderText="TotalExperienceYears"
SortExpression="TotalExperienceYears" />
<asp:BoundField DataField="TotalExperienceMonths" HeaderText="TotalExperienceMonths"
SortExpression="TotalExperienceMonths" />
<asp:BoundField DataField="ExperienceSummary" HeaderText="ExperienceSummary" SortExpression="ExperienceSummary" />
<asp:BoundField DataField="DetailedCVName" HeaderText="DetailedCVName" SortExpression="DetailedCVName" />
<asp:BoundField DataField="AdditionalQualification" HeaderText="AdditionalQualification"
SortExpression="AdditionalQualification" />
<asp:BoundField DataField="ExtraCurricular" HeaderText="ExtraCurricular" SortExpression="ExtraCurricular" />
<asp:BoundField DataField="Skills" HeaderText="Skills" SortExpression="Skills" />
<asp:BoundField DataField="TentativeFromDate" HeaderText="TentativeFromDate" SortExpression="TentativeFromDate" />
<asp:BoundField DataField="PageIndex" HeaderText="PageIndex" SortExpression="PageIndex" />
<asp:BoundField DataField="PersonalDetailID" HeaderText="PersonalDetailID" SortExpression="PersonalDetailID" />
<asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" SortExpression="DepartmentID" />
<asp:BoundField DataField="DesignationID" HeaderText="DesignationID" SortExpression="DesignationID" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString5 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString5.ProviderName %>" SelectCommand="SELECT * FROM [RESUME]">
</asp:SqlDataSource>
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center style="background-color: silver">
</center>
</div>
</form>
</body>
</html>
You don't have to do a postbask to redirect the user to the details page, you can edit your template column to go directly to the URL of the details page along with a GET variable of the ID needed for the lookup.
<asp:TemplateField HeaderText="Applicant Detail">
<ItemTemplate>
<asp:HyperLink NavigateUrl="DetailsView.aspx?ResumeID=" + "<%# Bind("ResumeID") %>" Text="Visit W3Schools!" Target="_blank" runat="server" />
</ItemTemplate>
</asp:TemplateField>
In your Details page, do Request.QueryString("ResumeID") to get ID needed to do the lookup.
Related
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 master page with me but when i run the shopcart page, it shows me the error "A page can have only one server-side Form tag". i dont know which runat to be removed
Any help would be appreciated thanks :)
this are my codes for master page
<asp:ContentPlaceHolder ID="headersContainer" runat="server" />
<div id="container">
<div id="header">
<div class="clear"></div>
</div>
<div id="nav">
<ul>
<li >Home</li>
<li>Orders</li>
<li>Cart</li>
<li>Shipment</li>
</ul>
</div>
<div id="body">
<div id="content">
<div style= "text-align:right";>
<form runat="server">
<asp:Button ID="Button1" runat="server" Text="Items in Shopping Cart" BackColor="#FF531A"
BorderStyle="Dotted" CausesValidation="False" ForeColor="White"
Font-Bold /></form></div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" >
</asp:ContentPlaceHolder>
</div>
       
<div class="sidebar">
<ul>
<li>
<h3>User</h3>
<ul class="blocklist">
<li>Register</li>
<li>Login</li
</ul>
</li>
 
<li>
<h3>Categories</h3>
<ul>
<li><a href="http://www.themeforest.net/?ref=spykawg" ><strong>Gadgets</strong></a></li>
<li><a href="http://www.dreamhost.com/r.cgi?259541" ><strong>Accessories</strong></a> </strong></li>
</ul>
</li>
 
<li>
<h3>Search</h3>
<ul>
<li>
<form method="get" class="searchform" action="http://wpdemo.justfreetemplates.com/" >
<p>
<input type="text" size="12" value="" name="s" class="s" />
<input type="submit" class="searchsubmit formbutton" value="Search" />
</p>
</form>
</li>
</ul>
</li>
</ul>
</div>
this are codes for my shopCart page
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id= "form1" runat="server">
<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" >
</asp:DropDownList>
<br />
<br />
<asp:GridView ID="grdCatalogue" runat="server" AutoGenerateColumns="False"
Width ="100px" onselectedindexchanged="grdCatalogue_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" >
<ControlStyle Width="80px" />
<FooterStyle Width="80px" />
<HeaderStyle Width="80px" />
<ItemStyle Width="80px" />
</asp:BoundField>
<asp:BoundField DataField="ProductName" HeaderText="ProductName" />
<asp:BoundField DataField="Price" HeaderText="Price" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" />
<asp:BoundField DataField="UserName" HeaderText="Sold By" />
<asp:BoundField DataField="Date" HeaderText="Date Uploaded" />
<asp:ImageField DataImageUrlField="Image1FileName"
DataImageUrlFormatString="~/Image/{0}" HeaderText="Image">
</asp:ImageField>
<asp:CommandField ButtonType="Button" HeaderText="Add to Cart"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
Remove runat="server" from form tag in your ShopCart
page.
You can remove your form tag too from shopcart page as your master page already contains Form tag.
You should remove the form tag from your shopCart page
In ASP.NET model, single server tag is responsible for all the page processing.
Your shopping cart page has
<form id= "form1" runat="server">
Which is not required as the contentplaceholder is already within a form. The contents of the contentplaceholder will be added to the master page.
You don't need another form on the shopCart page as you have one on your master page. The form on your master page is included on every page that uses your master page. so I would remove the following tag from the shopCart page;
<form id= "form1" runat="server">
You need to remove <form id= "form1" runat="server"> in your child page
because the ContentPlaceHolder1 is already have form tag in master page !
Update your shopping cart page
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" >
</asp:DropDownList>
<br />
<br />
<asp:GridView ID="grdCatalogue" runat="server" AutoGenerateColumns="False"
Width ="100px" onselectedindexchanged="grdCatalogue_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" >
<ControlStyle Width="80px" />
<FooterStyle Width="80px" />
<HeaderStyle Width="80px" />
<ItemStyle Width="80px" />
</asp:BoundField>
<asp:BoundField DataField="ProductName" HeaderText="ProductName" />
<asp:BoundField DataField="Price" HeaderText="Price" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" />
<asp:BoundField DataField="UserName" HeaderText="Sold By" />
<asp:BoundField DataField="Date" HeaderText="Date Uploaded" />
<asp:ImageField DataImageUrlField="Image1FileName"
DataImageUrlFormatString="~/Image/{0}" HeaderText="Image">
</asp:ImageField>
<asp:CommandField ButtonType="Button" HeaderText="Add to Cart"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
I want to create a Master Page that has a toolbar (add,edit,delete,approve,unapprove) as well as a gridview as shown below. This Master Page will have a lot of children. I want to reused the gridview and the toolbar.. rather than adding both of them to each page i create.
<%# Master Language="VB" AutoEventWireup="false" CodeBehind="JSPSite.master.vb" Inherits="SSPayroll.JSPSite" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="../Styles/Style1.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="Form1" runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/GSCV1.01 - Copy.png"
Height="73px" style="margin-top: 20px" Width="428px" />
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<LoggedInTemplate>
<asp:Label ID="Label2" runat="server" Text="User: " Font-Names="Cambria"></asp:Label><span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" Font-Names="Cambria" />
</span> [
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect"
LogoutPageUrl="~/" Font-Names="Cambria" Font-Size="Small" ForeColor="#D9D5D5" Font-Bold="True" LogoutText="Sign Out" />
]
<div>
</div>
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<asp:Label ID="Label1" runat="server" Text="Date/Time" Font-Names="Cambria"
Font-Size="Small" ForeColor="#333333"></asp:Label>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False"
IncludeStyleBlock="False" Orientation="Horizontal" BackColor="#FFFBD6"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" StaticSubMenuIndent="10px" Enabled="True">
<DynamicHoverStyle BackColor="#990000" ForeColor="White" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyle BackColor="#FFFBD6" />
<DynamicSelectedStyle BackColor="#FFCC66" />
<Items>
<asp:MenuItem Text="Menu1" Value="Tools">
<asp:MenuItem NavigateUrl="~/JSPayroll/Payment_Rules/PaymentRules.aspx" Text="Payment Rules" Value="Payment Rules"></asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticSelectedStyle BackColor="#FFCC66" />
</asp:Menu>
</div>
</div>
<asp:ContentPlaceHolder ID="ToolBarPlaceHolder" runat="server" >
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<div>
<hr />
<asp:ImageButton ID="ImageButton1" runat="server" Height="48px" ImageUrl="~/IconsPack/Home.png" Width="48px" ToolTip="Home" CssClass="morph" PostBackUrl="~/JSPayroll/JSPDefault.aspx"/>
<asp:ImageButton ID="ImageButton2" runat="server" Height="48px" ImageUrl="~/IconsPack/Add.png" PostBackUrl="~/JSPayroll/Payment_Rules/PaymentRulesDetails.aspx" ToolTip="Add Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton3" runat="server" Height="48px" ImageUrl="~/IconsPack/Edit E.png" ToolTip="Edit Record" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton4" runat="server" Height="48px" ImageUrl="~/IconsPack/ViewDetails.png" ToolTip="View Record Details" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton5" runat="server" Height="48px" ImageUrl="~/IconsPack/Delete.png" ToolTip="Delete Record" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton6" runat="server" Height="48px" ImageUrl="~/IconsPack/Approved.png" ToolTip="Approve Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton7" runat="server" Height="48px" ImageUrl="~/IconsPack/Denied.png" ToolTip="Unapprove Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton8" runat="server" Height="48px" ImageUrl="~/IconsPack/Update.png" ToolTip="Refresh Table" CssClass="morph" Width="48px"/>
<hr />
</div>
</asp:Panel>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="GridViewPlaceHolder" runat="server">
<div class="EU_TableScroll" id="showData" style="display: block">
<asp:GridView ID="GridView1" runat="server" CssClass="EU_DataTable" AllowPaging="True"
PageSize="7" AutoGenerateColumns="False" EmptyDataText="No Data Available.">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="DataSource" runat="server">
</asp:ContentPlaceHolder>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
An Example of a Child Page using the master page from above.
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/JSPayroll/JSPSite.Master" CodeBehind="PaymentRules.aspx.vb" Inherits="SSPayroll.PaymentRules" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="DS" ContentPlaceHolderID ="DataSource" runat ="server">
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=sspEntities" DefaultContainerName="sspEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="GeneralRules">
</asp:EntityDataSource>
</asp:Content>
Basically what i want to do is.. In my child page just configure the Data source for each page, attached it to the gridview from the master page and the preform my task.. add, edit, delete (buttons in my master page). I am new to this and dont really have an idea of how to go about this. Some help would be appreciated. Also If someone can tell me what i am doing actually makes sense rather than adding gridviews and toolbar to each page i create. Please let me know. Thank you.
EDITED - With Answer.
Dim ContentPlaceHolder As ContentPlaceHolder
Dim gv As GridView
ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder)
If Not ContentPlaceHolder Is Nothing Then
gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView)
If Not gv Is Nothing Then
Dim es As EntityDataSource = EntityDataSource1
gv.DataSource = es
gv.DataBind()
End If
End If
Dim ContentPlaceHolder As ContentPlaceHolder
Dim gv As GridView
ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder)
If Not ContentPlaceHolder Is Nothing Then
gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView)
If Not gv Is Nothing Then
Dim es As EntityDataSource = EntityDataSource1
gv.DataSource = es
gv.DataBind()
End If
End If
I feel almost stupid asking this because I think the answer is probably very basic. But, here it goes.
I am designing a website with a button that "rolls dice" then enables other buttons on the page (categories in my game), which ultimately, will use those buttons to go to the proper category. So, in effect, [click "roll ..."], the C# of the page (Game.aspx.cs) processes which buttons to enable, display/enable those buttons for click-ability.
My problem is this:
The page is
[domain]/UncommonSense/Game.aspx
but after I click the "roll ..." button the URL turns to
[domain]/Game.aspx#/Game.aspx
This causes a problem in the categories buttons because I need to redirect to
[domain]/UncommonSense/Question.aspx
but since Game.aspx#/ has taken the place of UncommonSense/ it fails.
CODE:
Okay, here is the code in my Game.aspx file. The button is the "ID=Roll" button listed right below "Label12." The code behind is literally right now a blank function so it is not doing anything on the C# side except posting back (apparently). However, when that button is clicked the URL goes from:
[domain]/UncommonSense/Game.aspx
to
[domain]/Game.aspx#/Game.aspx
NOTE: I just tested from a root directory and it did about the same thing:
[domain]/Game.aspx
became
[domain]/Game.aspx#/Game.aspx
Maybe this has something to do with the form?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Game.aspx.cs" Inherits="Uncommon_Sense.Game" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Uncommon Sense</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
<form id="form1" runat="server">
<div data-role="page">
<div data-role="header" data-theme="b">
<h1><asp:Label ID="Label1" runat="server" Text="Uncommon Sense"></asp:Label></h1>
</div>
<div data-role="content">
<h4><asp:Label ID="Label4" runat="server" Text="Game Statistics"></asp:Label></h4>
<asp:Label ID="Label11" runat="server" data-mini="true" Text=""></asp:Label>
<asp:Label ID="Label10" runat="server" data-mini="true" Text=""></asp:Label>
<h4><asp:Label ID="Label2" runat="server" Text="Game Play"></asp:Label></h4>
<asp:Button ID="Roll" runat="server" Text="Roll Dice ..." data-mini="true"
onclick="Roll_Click" />
<hr width="80%" />
<div class="ui-grid-c">
<div class="ui-block-a">
<asp:Button ID="btnShortStuffChecked" runat="server" Text="Short Stuff" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnShortStuffNotChecked" runat="server" Text="Short Stuff" data-mini="true"
Enabled="False" Visible="False" onclick="btnShortStuffNotChecked_Click" /></div>
<div class="ui-block-b">
<asp:Button ID="btnWhoSaidChecked" runat="server" Text="Who Said?" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnWhoSaidNotChecked" runat="server" Text="Who Said?" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-c">
<asp:Button ID="btnCommonQuipChecked" runat="server" Text="Common Quip" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnCommonQuipNotChecked" runat="server" Text="Common Quip" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-d">
<asp:Button ID="btnRhymeTimeChecked" runat="server" Text="Rhyme Time" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnRhymeTimeNotChecked" runat="server" Text="Rhyme Time" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-a">
<asp:Button ID="btnAnythingGoesChecked" runat="server" Text="Anything Goes" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnAnythingGoesNotChecked" runat="server" Text="Anything Goes" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-b">
<asp:Button ID="btnDefineItChecked" runat="server" Text="Define It" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnDefineItNotChecked" runat="server" Text="Define It" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-c">
<asp:Button ID="btnAllAbroadChecked" runat="server" Text="All Abroad" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnAllAbroadNotChecked" runat="server" Text="All Abroad" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-d">
<asp:Button ID="btnSpellItChecked" runat="server" Text="Spell It" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnSpellItNotChecked" runat="server" Text="Spell It" data-mini="true"
Enabled="False" Visible="False" /></div>
</div>
<h4><asp:Label ID="Label3" runat="server" Text="Settings"></asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Question.aspx">HyperLink</asp:HyperLink>
</h4>
<label for="slider-0">Computer Difficulty:</label>
<input type="range" name="slider" id="slider-0" value="2" min="1" max="4" />
<h3><asp:Label ID="Label5" runat="server" Text="Label"></asp:Label></h3>
<asp:Button ID="ChoiceA" runat="server" Text="Button" onclick="ChoiceA_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" Visible="False" />
<asp:Button ID="Button3" runat="server" Text="Button" Visible="False" />
</div>
</div>
</form>
</body>
</html>
UPDATE:
And the answer is ... JQuery Mobile!
By simply removing the reference to JQuery Mobile the problem is solved so apparently this is something in their library that changes URLs. That sucks because I liked using JQuery Mobile. Oh well, my comments will stop now on the annoyance because I am appreciative of the 99.9% of the stuff they do that helps. But, for the record...
ANY LINK will have:
linker.aspx
changed to:
linker#/linker.aspx
for some reason.
I have the following which works fine:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="test_library_newsletter_Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-family:Arial;">
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="false"
emptydatatext="No data available."
allowpaging="true"
runat="server"
ShowHeader="True"
GridLines="None"
CellPadding="10">
<Columns>
<asp:BoundField HeaderText="Date"
DataField="date"
dataformatstring="{0:dd-MM-yyyy}" />
<asp:HyperLinkField HeaderText="Subject"
DataTextField="subject"
DataNavigateUrlFields="id"
DataNavigateUrlFormatString="http://intranet/Default2.aspx?id={0}" />
</Columns>
<pagersettings mode="Numeric"
position="Bottom"
pagebuttoncount="10"/>
<HeaderStyle HorizontalAlign="Left" />
</asp:gridview>
<asp:sqldatasource id="CustomersSource"
selectcommand="select id, subject, date from table order by id desc"
connectionstring="connection string here"
runat="server"/>
</div>
</form>
</body>
</html>
However, I want to use a querystring value in the sql statement. How do I do that?
you need something like this
<asp:SqlDataSource ID="ID" runat="server" ConnectionString="connectionString"
ProviderName="providerName"
SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice] FROM [Products] WHERE ([CategoryID] = ?)">
<SelectParameters>
<asp:QueryStringParameter Type="Int32"
Name="CategoryID"
QueryStringField="CategoryID" />
</SelectParameters>
</asp:SqlDataSource>
Read full post at
https://web.archive.org/web/20211020150717/https://www.4guysfromrolla.com/articles/030106-1.aspx
Hope it helps.