im having trouble of making a gridview work. the functionality is simple but im a little lost on how to make it work.
my interface looks like this
________________________________________________________________________________
now each item inside the dropdownlist is declared like this:
the value up there indicates a field name within my "unit" table.
_____________________________________________________________________
heres my code under my btn_click event:
SqlDataSource1.SelectCommand = "SELECT * FROM [Unit] WHERE (' @DropDownList1 ' LIKE '%' + @UnitDesc + '%')";
SqlDataSource1.DataBind();
btw @UnitDesc is the name of the textbox for the search input.
although it doesnt show any error, it doesnt work though. my datagrid wont show up.
what am i doing wrong?
Kirtan PatelPosted Nov 22, 2009, 7:43 AM
SqlDataSource1.DataBind();
to
SqlDataSource1.SelectCommand = "SELECT * FROM [Unit] WHERE ("+DropDownList1.SelectedValue.ToString()+"' LIKE '%' + txtUnitDesc.Text + '%')";
GridView1.DataBind();
Mark UyPosted Nov 22, 2009, 7:10 AM
Kirtan PatelPosted Nov 22, 2009, 6:49 AM
Instead of Firing "SqlDataSource1.DataBind() " method
Use
GridView1.DataBind() method after changing Select command Of SQLDataSource1 :)
that will work :)
it still not solved problem then let me know :)