I have a gridview, where I have made autocode using the wizard.
However I need a dynamic SQLcommand from server side.
I have tried this code, but it doesn't work, it works if I use this code from HTML (setting the sqlcommand in the SQLDataSource.
I have deleted the sqlcommand from the HTML and instead I have implemented the code in the page_load event:
But this code works, when I apply the SQLCommand in HTML:Code:Dim str As String = SqlDataSource1.SelectCommand = "SELECT DISTINCT Beregning.bId, Informationer.Dato,Beregning.bType, Informationer.pNavn, Informationer.pNr, Informationer.Beskr, Beregning.uId FROM Beregning CROSS JOIN Informationer WHERE (Beregning.UserId = @UserId) AND Beregning.uId = Informationer.uId AND (Beregning.bType=@berType2) ORDER BY Beregning.bId DESC" SqlDataSource1.SelectCommand = str
Code:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IsoPlusConnectionStringDrift %>" SelectCommand='SELECT DISTINCT Beregning.bId, Informationer.Dato,Beregning.bType, Informationer.pNavn, Informationer.pNr, Informationer.Beskr, Beregning.uId FROM Beregning CROSS JOIN Informationer WHERE (Beregning.UserId = @UserId) AND Beregning.uId = Informationer.uId AND (Beregning.bType=@berType) ORDER BY Beregning.bId DESC'> <SelectParameters> <asp:SessionParameter Name="UserId" SessionField="userId" /> <asp:Parameter DefaultValue="Optimering" Name="berType" /> <asp:Parameter DefaultValue="Kapacitet" Name="berType2" /> <asp:Parameter DefaultValue="Varmetab - Alle rørtyper" Name="berType3" /> <asp:Parameter DefaultValue="Varmetab - Nuværdi" Name="berType4" /> <asp:Parameter DefaultValue="Nomogram" Name="berType5" /> <asp:Parameter DefaultValue="Temperatur - Afkølingsgraf" Name="berType6" /> </SelectParameters> </asp:SqlDataSource>




Reply With Quote