本文介绍了如何在C#中获取带有查询字符串ID的匹配值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人告诉我如何在c#中获取与querystring id匹配的值,我能够在vb.net中执行代码,但是我的代码在使用c#编码与查询字符串时抛出错误,我的代码是

Pls someone tell that how to get matching values with querystring id in c#, i am able to do code in vb.net but my code is throwing error with c# coding with query string, my code is

If Request.QueryString("ID") <> "" AndAlso Request.QueryString("ID") IsNot Nothing Then
                'Dim cmd As New SqlClient.SqlCommand("SELECT * FROM news WHERE id=" + Request.QueryString("ID"), sqlcon)
                If Request.QueryString("ID") = 1 Then
                    ada = New SqlClient.SqlDataAdapter("SELECT * from teammanage where saveas='Under 10'", sqlcon)
                    dt = New DataTable("dell")
                    ada.Fill(dt)
                    If dt.Rows.Count > 0 Then
                        tit = dt.Rows(0)("name").ToString()
                        detail = dt.Rows(0)("photo").ToString()
                    End If




请有人告诉我如何在c#中执行代码,以及如何在数据列表中显示.

请帮助纠正此代码.




Pls someone tell that how to do code in c#, and how to display in datalist.

Pls help to correct this code.

推荐答案


if (Request.QueryString["CatId"] != null)
                {
                   if(Convert.ToInt32(Request.QueryString["CatId"])==2)
                  {
                           //Your Code
                  }

                }


这篇关于如何在C#中获取带有查询字符串ID的匹配值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 08:50