Hello everyone,
I am using VS2005 (C#) and have the following code behind for my login page. When I try to compile it, I get the following error on the line in bold below. Seems like I need to convert "UserName" and "Password" to strings. Can someone please help me with this?
Thanks,
Kathy
error
Argument'1': cannot convert from 'System.Web.UI.WebControls.TextBox' to 'string'
code behind
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Configuration;
using LoginInfoTableAdapters;
namespace LoginTest
{
public partial class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox UserName;
protected System.Web.UI.WebControls.RequiredFieldValidator rvUserValidator;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.RequiredFieldValidator rvPasswordValidator;
protected System.Web.UI.WebControls.Button cmdSubmit;
protected System.Web.UI.WebControls.ValidationSummary Validationsummary1;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Label lblMessage2;
private void Page_Load(object sender, System.EventArgs e)
{
}
protected void cmdSubmit_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
tblPeopleTableAdapter LoginAdapter = new tblPeopleTableAdapter();
LoginInfo.tblPeopleDataTable Criteria =
LoginAdapter.GetDataBy(UserName, Password);
this.GridView1.DataSource = Accounts;
this.GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
I am using VS2005 (C#) and have the following code behind for my login page. When I try to compile it, I get the following error on the line in bold below. Seems like I need to convert "UserName" and "Password" to strings. Can someone please help me with this?
Thanks,
Kathy
error
Argument'1': cannot convert from 'System.Web.UI.WebControls.TextBox' to 'string'
code behind
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Configuration;
using LoginInfoTableAdapters;
namespace LoginTest
{
public partial class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox UserName;
protected System.Web.UI.WebControls.RequiredFieldValidator rvUserValidator;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.RequiredFieldValidator rvPasswordValidator;
protected System.Web.UI.WebControls.Button cmdSubmit;
protected System.Web.UI.WebControls.ValidationSummary Validationsummary1;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Label lblMessage2;
private void Page_Load(object sender, System.EventArgs e)
{
}
protected void cmdSubmit_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
tblPeopleTableAdapter LoginAdapter = new tblPeopleTableAdapter();
LoginInfo.tblPeopleDataTable Criteria =
LoginAdapter.GetDataBy(UserName, Password);
this.GridView1.DataSource = Accounts;
this.GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}