Hi micah,
I have created sample which fullfill requirement.
HTML
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtuserName" runat="server" />
<br />
<br />
<asp:TextBox ID="txtPassword" TextMode="Password" runat="server" />
<br />
<br />
<asp:Button ID="btnLogin" Text="Login" runat="server" OnClick="Unnamed1_Click" />
<asp:Button ID="btnCancel" Text="Cancel" runat="server" OnClick="btnCancel_Click"
Style="height: 26px" />
<br />
<br />
<asp:FormView ID="FormView1" runat="server" OnDataBound="FormView1_DataBound">
<ItemTemplate>
<asp:Image ID="Image1" Width="200px" Visible="false" Height="100px" ImageUrl="~/images/Desert.jpg"
runat="server" />
<br />
<asp:HiddenField ID="hfStatus" Value='<%#Eval("Status")%>' runat="server" />
<br />
</ItemTemplate>
</asp:FormView>
</div>
</form>
C#
private string Constr = ConfigurationManager.ConnectionStrings["Constr"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Unnamed1_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(Constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT UserName, status FROM UserLogin WHERE UserName= '" + txtuserName.Text + "' AND Password ='" + txtPassword.Text + "'", con))
{
DataTable dt = new DataTable();
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(dt);
FormView1.DataSource = dt;
FormView1.DataBind();
}
}
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect(Request.Url.AbsoluteUri);
}
protected void FormView1_DataBound(object sender, EventArgs e)
{
if ((FormView1.FindControl("hfStatus") as HiddenField).Value == "True")
{
(FormView1.FindControl("Image1") as Image).Visible = true;
}
}
SQL
CREATE TABLE UserLogin
(
UserId INT IDENTITY CONSTRAINT PK_UID PRIMARY KEY NOT NULL
,UserName VARCHAR(50) NOT NULL
,Status VARCHAR(10)
);
I hope works for you.