Last post Apr 24, 2011 06:21 PM by Paulanthony2010
Apr 20, 2011 01:36 AM|Paulanthony2010|LINK
Hi there, I'm using the query builder in Visual web developer 2010 express and I'm trying to make a query a sql datasource.
The "top down" description of the query would be this:
select for each index in the table column(s) A,B,C if D greater than E,
or If D > E write then write out A,B,C (i'm sure you have it by now)
I want to get D and E from the datagrid, not have to type anything in so I dont want a control on the form.
I just want the form to load and list all items (A,B,C) IF THE VALUE IN COLUMN D IS GREATER THAN COLUMN E.
Ive been playing around with the query builder and can get D from the WHERE clause but always seem to end up having to
enter a parameter for E, (not practical for couple hundred items)
oh and the paramters are integers by the way
thanks in advance for any suggestions
Apr 20, 2011 01:07 PM|oscar07202|LINK
protected void Page_Load(object sender, EventArgs e)
--reload the datagrid, everytime
select table.a, table.b, table.c
where table.d > table.e
^^^^^^^^^^^ something along those lines for the sqldatasource?
Apr 22, 2011 09:04 PM|Decker Dong - MSFT|LINK
My addition to the 2nd man's——
You should use a SqlDataSource with the 2nd man's advice and have a test, then bind the SqlDataSource to the GridView or DataGrid. Futhermore, I think you should confirm that the column "E: is really in your db, and you can try this way:
<asp:SqlDataSource …… SelectCommand="select a,b,c from table where d>@e">
<asp:Parameter Name="@e" type="Int" DefaultValue="1"/>
Then handle the SqlDataSource_Selecting event, try to say this:
e.Parameters["@e"].DefaultValue = Some Value that you want to filter with
Apr 24, 2011 06:16 PM|Paulanthony2010|LINK
Thanks for your help
Apr 24, 2011 06:17 PM|Paulanthony2010|LINK
Apr 24, 2011 06:21 PM|Paulanthony2010|LINK
I'm going to mark this as answer because it is precisely what I asked for. However the other guys answer was pretty useful too.