Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate a table based on a selection from a dynamic drop down?
    primarykey
    data
    text
    <p>so I am learning ASP.NET currently and actually today is my second day.</p> <p>So right now I am wanting to create a page where I have first a dynamically generated dropdown that selects just the first name from my database and table. This I have working</p> <p>Next I have a gridview table that shows all the data from the database, currently I have hard coded a name so the page will not crash (there are 100000 rows of data)</p> <p>Lastly when I post my code you will see a checkbox, that is just so when I click it the gridview will show up. I am just trying that out, because that was part of a lesson I learned today.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;h1&gt;Test of First Database pull&lt;/h1&gt; &lt;asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" Text="Show Panel" OnCheckedChanged="checkbox1_CheckedChanged" /&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="FirstName" DataValueField="FirstName" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"&gt;&lt;/asp:DropDownList&gt; &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ASP.NETConnectionString1 %&gt;" ProviderName="&lt;%$ ConnectionStrings:ASP.NETConnectionString1.ProviderName %&gt;" SelectCommand="SELECT DISTINCT [FirstName] FROM [SampleData] ORDER BY 'FirstName' "&gt;&lt;/asp:SqlDataSource&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:Panel ID="Panel1" runat="server" Visible="False" &gt; &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="SSN" HeaderText="SSN" SortExpression="SSN" /&gt; &lt;asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /&gt; &lt;asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /&gt; &lt;asp:BoundField DataField="HomeStreet" HeaderText="HomeStreet" SortExpression="HomeStreet" /&gt; &lt;asp:BoundField DataField="HomeCity" HeaderText="HomeCity" SortExpression="HomeCity" /&gt; &lt;asp:BoundField DataField="HomeState" HeaderText="HomeState" SortExpression="HomeState" /&gt; &lt;asp:BoundField DataField="HomeZip" HeaderText="HomeZip" SortExpression="HomeZip" /&gt; &lt;asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" /&gt; &lt;asp:BoundField DataField="CompanyStreet" HeaderText="CompanyStreet" SortExpression="CompanyStreet" /&gt; &lt;asp:BoundField DataField="CompanyCity" HeaderText="CompanyCity" SortExpression="CompanyCity" /&gt; &lt;asp:BoundField DataField="CompanyState" HeaderText="CompanyState" SortExpression="CompanyState" /&gt; &lt;asp:BoundField DataField="CompanyZip" HeaderText="CompanyZip" SortExpression="CompanyZip" /&gt; &lt;asp:BoundField DataField="HomePhone" HeaderText="HomePhone" SortExpression="HomePhone" /&gt; &lt;asp:BoundField DataField="CompanyPhone" HeaderText="CompanyPhone" SortExpression="CompanyPhone" /&gt; &lt;asp:BoundField DataField="CellPhone" HeaderText="CellPhone" SortExpression="CellPhone" /&gt; &lt;asp:BoundField DataField="DateOfBirth" HeaderText="DateOfBirth" SortExpression="DateOfBirth" /&gt; &lt;asp:BoundField DataField="DateOfHire" HeaderText="DateOfHire" SortExpression="DateOfHire" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ASP.NETConnectionString1 %&gt;" ProviderName="&lt;%$ ConnectionStrings:ASP.NETConnectionString1.ProviderName %&gt;" SelectCommand="SELECT [SSN], [LastName], [FirstName], [HomeStreet], [HomeCity], [HomeState], [HomeZip], [CompanyName], [CompanyStreet], [CompanyCity], [CompanyState], [CompanyZip], [HomePhone], [CompanyPhone], [CellPhone], [DateOfBirth], [DateOfHire] FROM [SampleData] WHERE [FirstName] = 'Bob' "&gt;&lt;/asp:SqlDataSource&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is my C# part where i call the session</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Demos_GridView : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string name = DropDownList1.SelectedValue; Session["FName"] = name; } protected void checkbox1_CheckedChanged(object sender, EventArgs e) { Panel1.Visible = CheckBox1.Checked; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { } } </code></pre> <p>As you see I called the session "I believe" I tried using this</p> <pre><code> &lt;%:Session["user"]%&gt; </code></pre> <p>within that sql query but it was saying I could not have the &lt;%%> within the asp sql calling. So if anyone could help me out that would be amazing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload