Hi,
I try to insert the date parameter on SQL line.
The date parameter is on ASP var declares.
I'm working with the page that have listbox, and gridview bound to msaccess.
when the user select thelistbox with other value, the page will reload.
while the page reload on server, it carry the variable that should insert on sql line,
for displaying the difference gridview records result.
So I have dynamic gridview records base on my listbox.
But, ... the page doesn't load well from the beginning. Doesn't work at all !!
I declare this at the page load.
Dim StartProjectAsString ="1/1/1996"
Sub ProjectListBox_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs EventArgs)Handles PYear.SelectedIndexChanged
StartProject = PYear.SelectedValue.ToString
EndSub
The object "Pyear" is listbox :
<asp:ListBoxID="PYear"runat="server"Rows="12"CssClass="tb01"SelectionMode="Single"AutoPostBack="True">
<asp:ListItemValue="1/1/1991">1991-1995</asp:ListItem>
<asp:ListItemValue="1/1/1996"Selected="True">1996-2000</asp:ListItem>
<asp:ListItemValue="1/1/2001">2001-2005</asp:ListItem>
<asp:ListItemValue="1/1/2006">2006-2010</asp:ListItem>
<asp:ListItemValue="1/1/2011">2011-2015</asp:ListItem>
</asp:ListBox>
And the datasource for bound to gridview is
<asp:AccessDataSourceID="AccessDataSource1"runat="server"DataFile="~/App_Data/general.mdb"
SelectCommand='SELECT TBL_PROJECT.NAMEPROJECT AS Name, TBL_PROJECT.STARTPROJECT AS Start, TBL_PROJECT.ENDPROJECT AS Finish, TBL_PROJECT.JOBNO AS JobNo, TBL_PROJECT.CLIENT AS Client, TBL_PROJECT.BUILDING AS Building, TBL_PROJECT.CODEPROJECT AS Code, TBL_PROJECT.IDPROJECT AS IDPROJECT FROM TBL_PROJECT WHERE TBL_PROJECT.STARTPROJECT >= DateValue("<%=StartProject%>") And TBL_PROJECT.STARTPROJECT < DateValue("1/1/2001");'>
</asp:AccessDataSource>
It will return the error page regarding the ASP : StartProject.
If I change the variable with the string "1/1/1996" :
'SELECT TBL_PROJECT.NAMEPROJECT AS Name, TBL_PROJECT.STARTPROJECT AS Start, TBL_PROJECT.ENDPROJECT AS Finish, TBL_PROJECT.JOBNO AS JobNo, TBL_PROJECT.CLIENT AS Client, TBL_PROJECT.BUILDING AS Building, TBL_PROJECT.CODEPROJECT AS Code, TBL_PROJECT.IDPROJECT AS IDPROJECT FROM TBL_PROJECT WHERE TBL_PROJECT.STARTPROJECT >= DateValue("1/1/1996") And TBL_PROJECT.STARTPROJECT < DateValue("1/1/2001");
it will work fine, but I will miss my dynamic gridview, right ?
So, please ... help me ...
Thank you ...
The answer :
http://forums.asp.net/t/1110547.aspx
No comments:
Post a Comment