I'm actually storing a value using session and then redirecting to other page using image button where based on the session value I'm fetching the Data from database. I'm getting an user defined exception in the line. please help!
adap.Fill(dt1);//[SqlException (0x80131904): Incorrect syntax near '='.]
And this my coding.
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton btn = sender as ImageButton;
string modelId = btn.CommandArgument;
Session["modelid"] = modelId;
Response.Redirect("details.aspx");
}
public partial class details : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=VISH;Initial Catalog=VISH;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter adap = new SqlDataAdapter("select * from details1 where Modelid=" + Session["modelid"], con);
DataTable dt1 = new DataTable();
adap.Fill(dt1);
DataList1.DataSource = dt1;
DataBind();
}