Hello,
There seem to be a problem with my GridView when I navigate to dashboard page where the grid view is.
For example, after I log in to the platform and navigate to a page where I have Grid-view that display records from data table an error is received on the browser.
Conversion failed when converting the varchar value 'ukosimons@gmail.com' to data type int
Here is my Grid-view code that displays records from data table.
if (!this.IsPostBack)
{
this.BindGrid();
}
private void BindGrid()
{
string sql = "SELECT * FROM Users WHERE CreatedBy=@CreatedBy OR @CreatedBy = ''";
using (SqlCommand cmd = new SqlCommand(sql))
{
cmd.Parameters.AddWithValue("@CreatedBy", Session["user"]);
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
AdminGrid.DataSource = dt;
AdminGrid.DataBind();
}
}
}
}