Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# QueryString—当参数为';未指定_C#_Asp.net_Query String - Fatal编程技术网

C# QueryString—当参数为';未指定

C# QueryString—当参数为';未指定,c#,asp.net,query-string,C#,Asp.net,Query String,我使用的是Visual Studio和C#,我有一个数据列表,可以显示我数据库中的游戏。我使用QueryString来确定要显示的流派(类别) 数据列表中填充了游戏标题和图像,我的SqlDataSource如下所示: <asp:sqldatasource id="SqlDataSourceGames" runat="server" connectionstring="<%$ ConnectionStrings:gamesconstring %>" selectcomma

我使用的是Visual Studio和C#,我有一个数据列表,可以显示我数据库中的游戏。我使用QueryString来确定要显示的流派(类别)

数据列表中填充了游戏标题和图像,我的SqlDataSource如下所示:

<asp:sqldatasource id="SqlDataSourceGames" runat="server" connectionstring="<%$ ConnectionStrings:gamesconstring %>"
    selectcommand="SELECT uname, uimg
                    FROM games 
                    INNER JOIN categories_games
                    ON games.uid = categories_games.uid
                    INNER JOIN consoles_games
                    ON games.uid = consoles_games.uid
                    WHERE consoleid = 2
                    AND categoryid = @categoryid">
    <SelectParameters>
        <asp:QueryStringParameter Name="categoryid" DbType ="String" Direction="Input" QueryStringField="categoryid" DefaultValue="" ConvertEmptyStringToNull="true" />   
    </SelectParameters>
</asp:sqldatasource>

这很好,我可以通过输入localhost/PS4.aspx?categoryid=1来指定流派。但是,如果没有指定categoryid,我希望显示所有类型。换句话说,当我转到localhost/PS4.aspx时

我尝试使用
CancelSelectOnNullParameter=“false”
,但没有任何效果。

使用

...    
selectcommand="SELECT uname, uimg
                FROM games 
                INNER JOIN categories_games
                ON games.uid = categories_games.uid
                INNER JOIN consoles_games
                ON games.uid = consoles_games.uid
                WHERE consoleid = 2
                AND (categoryid = @categoryid OR @categoryid IS NULL)"

CancelSelectOnNullParameter="false">
使用


完美,正是我错过的。谢谢完美,正是我错过的。谢谢