<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <span style="font-size: large; color: #000066">Here you go <asp:Label ID="Label2" runat="server" Font-Names="Algerian"></asp:Label> , this is your final outcome and prediction of your amazing personality!</span><p> <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Medium" Text="Label"></asp:Label> </p> <p> <span style="font-size: medium"> Result from Quiz</span></p> <p> <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" Height="288px" Width="391px"> <AlternatingRowStyle BackColor="White" /> <EditRowStyle BackColor="#7C6F57" /> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#E3EAEB" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F8FAFA" /> <SortedAscendingHeaderStyle BackColor="#246B61" /> <SortedDescendingCellStyle BackColor="#D4DFE1" /> <SortedDescendingHeaderStyle BackColor="#15524A" /> </asp:GridView> </p> </asp:Content>
using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace PERSODICT { public partial class outcome : System.Web.UI.Page { private static string cs = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString; protected void Page_Load(object sender, EventArgs e) { if (Session["username"] != null) { Label2.Text = Session["username"].ToString(); } else { } Label3.Text = DateTime.Now.ToString("D"); if (!this.IsPostBack) { this.GridView1.DataSource = GetData(); this.GridView1.DataBind(); } //using (SqlConnection con = new SqlConnection(cs)) //{ // con.Open(); // SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM quizresult", con); // DataTable dtbl = new DataTable(); // sqlDa.Fill(dtbl); // GridView1.DataSource = dtbl; // GridView1.DataBind(); //} } private DataTable GetData() { //string ConString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString; string query = "SELECT * FROM quizresult WHERE name = @Label2 "; SqlCommand cmd = new SqlCommand(query); cmd.Parameters.AddWithValue("@Label2", !string.IsNullOrEmpty(this.Page.User.Identity.Name) ? this.Page.User.Identity.Name : (object)DBNull.Value); using (SqlConnection con = new SqlConnection(cs)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); return dt; } } } } } }
CREATE TABLE [dbo].[quizresult] ( [Id] INT IDENTITY (1, 1) NOT NULL, [name] NCHAR (10) NULL, [description] NVARCHAR (MAX) NULL, [job] NVARCHAR (MAX) NULL, PRIMARY KEY CLUSTERED ([Id] ASC) );
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)