嗯,我已经尝试了所有你的人建议,但问题仍然相同特殊字符不显示在GridView控件从SQL数据库参数
让我告诉你在简短:
表姓名:AuzineForum。 ASPX
拥有1个GridView控件使用SELECT * FROM QF
其工作良好,指数也在努力,GridView控件有按钮,显示数据库中的所有领域和onClick我打开新的表单AuzineForumAnswer.aspx ..OK
我想从AuzineForum.aspx中选择一个记录,并显示在AuzineForumAnswer.aspx以及它发生在http://stackoverflow.com这里(我们点击线程然后新页面打开其中有问题,并在其上点击我们前面的答案)... OK
等AuzineForum.aspx的按钮的代码是
Button lb = (Button)sender;
GridViewRow row = (GridViewRow)lb.NamingContainer;
if (row != null)
{
int index = row.RowIndex; //gets the row index selected
Label AID1 = (Label)ForumQuesView.Rows[index].FindControl("AID1");
Label AID2 = (Label)ForumQuesView.Rows[index].FindControl("AID2");
Label AID3 = (Label)ForumQuesView.Rows[index].FindControl("AID3");
HyperLink Question = (HyperLink)ForumQuesView.Rows[index].FindControl("Question");
Label Questiontags = (Label)ForumQuesView.Rows[index].FindControl("Questiontags");
Label Askedby = (Label)ForumQuesView.Rows[index].FindControl("Askedby");
Response.Redirect(String.Format("AuzineForumAnswer.aspx?Question=" + Question.Text + "&Questiontags=" + Questiontags.Text + "&Askedby=" + Askedby.Text + "&AID1=" + AID1.Text + "&AID2=" + AID2.Text + "&AID3=" + AID3.Text, Server.UrlEncode(Question.Text), Server.UrlEncode(Questiontags.Text), Server.UrlEncode(Askedby.Text), Server.UrlEncode(AID1.Text), Server.UrlEncode(AID2.Text), Server.UrlEncode(AID3.Text)));
我有经过了太多的参数监守精度......
现在,当我运行它,然后单击按钮,它的开放AuzineForumAnswer.AuzineForumAnswerand显示,记录非常好,但出现问题时,qtags领域有“#”型喜欢这里的标签数据(C#,GridView的,等等),因此,当标记字段具有数据INCLUDIN“#” chracter然后它给出“对象refrence不设置到对象的实例”,并且如果有qtags像正常数据(specialcharacter gridview的SQL C)然后将其打开AuzineForumAnswer。ASPX并没有错误的数据显示
AuzineForumAnswer.aspx后面的代码如下
protected void GetAllData()
{
string connection = System.Configuration.ConfigurationManager.ConnectionStrings["AuzineConnection"].ConnectionString;
using (SqlConnection sqlconn = new SqlConnection(connection))
{
using (SqlCommand sqlcomm = sqlconn.CreateCommand())
{
sqlcomm.CommandText = "Select * From QF where Question='" + Server.UrlDecode(Request.QueryString["Question"].ToString()) + "' And qtags='" + Server.UrlDecode(Request.QueryString["Questiontags"].ToString()) + "' And UserFullName='" + Server.UrlDecode(Request.QueryString["Askedby"].ToString()) + "' And AID1='" + Server.UrlDecode(Request.QueryString["AID1"].ToString()) + "' And AID2='" + Server.UrlDecode(Request.QueryString["AID2"].ToString()) + "' And AID3='" + Server.UrlDecode(Request.QueryString["AID3"].ToString()) + "'";
SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);
DataTable dt = new DataTable();
sda.Fill(dt);
try
{
sqlconn.Open();
ForumQuesView.DataSource = dt;
ForumQuesView.DataBind();
ForumQuesView.AllowPaging = true;
}
catch (Exception ex)
{
Status.Text = ex.Message.ToString();
}
}
}
}
现在我也搞不懂什么问题在这里,因为只有qtags和的问题有两个网络连接场中,用户可以储存数据,因为他们想要的,问题是文字和qtags而且都煤焦领域,但问题并不在数据库中的问题是在这里以字符#
您是否尝试过调试和看到的是创造了什么SQL语句?发布该sql语句。 – unlimit
调试,获取查询并在sql server中运行它。我什么也没有出错,那么你的任何对象的初始化必须有问题 - “对象引用没有设置为对象的实例” – polin
亲爱的波林,我也同意你的意见,但我所说的是......我在qtags列中有很多行,通过单击任何行都没有出错,但具有“#”字符的行会给出错误,并且当我直接转到SQL Server以更改行内部时,它会给出错误“Binary data将被截断“现在这个错误来时,限制超过,但一切都很好,我不明白我在哪里犯的错误 –