kro*_*991 2 c# asp.net parameters gridview
如何从aspx页面的URL获取参数?
我有一个带有参数的应用程序?id=12345abcd,我想获取此 id 以在我的 gridview 中选择命令
SelectCommand="SELECT [a], [b], [c], [d], [e], [f], [g], [h], [c] FROM [table] WHERE [c] = parameterFromUrl"
Run Code Online (Sandbox Code Playgroud)
并从paramterFromUrl查询中的变量内的 url 插入此 id。
您可以Id通过查看Request.QueryString代码中的属性来访问它。对于您的用例,在后面的代码中,访问该 Id:
string Id= Request.QueryString["id"].ToString();
Run Code Online (Sandbox Code Playgroud)
并在你的SelectCommandas 中使用它:
SelectCommand="SELECT [a], [b], [c], [d], [e], [f], [g], [h], [c] FROM [table] WHERE [c] =" + Id;
Run Code Online (Sandbox Code Playgroud)
请注意sql注入
| 归档时间: |
|
| 查看次数: |
11488 次 |
| 最近记录: |