I am having an interesting problem in visual studio (likely due to my lack of experience). I have a SqlDataSource object and a GridView object. The Gridview object is setup to use the SqlDataSource as a source.
The SqlDataSource is using a parameter (Source = Control, its a textbox), to pass as an input into a SQL stored procedure to return a recordset. When I step through the code, on change to the textbox I execute SqlDataSource.Insert()
, then GridView.DataBind()
.
Since I was having issues with not getting the results I was expecting I ran a trance in SQL Server Profiler.
It seems that when SqlDataSource.Insert()
runs, a null value is passed through the parameter. When GridView.DataBind()
runs on the next line, the parameter value is passed properly.
Any ideas what could be causing this? I believe whatever I am doing wrong here is also affecting other areas of my code.
protected void ItemBox_TextChanged(object sender, EventArgs e)
{
if(setFire)
{
SqlDataSource1.Insert();
GridView1.DataBind();
Label1.Text = GridView1.Rows.Count.ToString() + " Results Found";
Label2.Text = ItemBox.Text;
setFire = false;
ItemBox.Text = "";
ItemBox.Focus();
setFire = true;
}
}