我正在尝试修改现有代码(由我的前任编写),将撇号(与测试一起输入到文本框中)更改为“Å”符号,同时将其显示回文本框中。我怎样才能改变这个?当我试图从代码中删除符号时,我无法取回结果/查看文本框中保存的文本,并给出错误消息。
这是显示结果的网格视图控件的代码,我想在这里单击以查看输入的数据:
protected void grdActivities_RowDataBound(Object sender, GridViewRowEventArgs e)
{
DataRowView dr = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblPerson = (Label)e.Row.FindControl("lblPerson");
if (dr["Name"] != DBNull.Value)
lblPerson.Text = dr["Name"].ToString();
Label lblDate = (Label)e.Row.FindControl("lblDate");
if (dr["service_outcome_date"] != DBNull.Value)
lblDate.Text = dr["service_outcome_date"].ToString();
Label lblReasonforContact = (Label)e.Row.FindControl("lblReasonforContact");
if (lblReasonforContact != null)
{
if (dr["reason_for_contact_desc"] != DBNull.Value)
{
lblReasonforContact.Text = dr["reason_for_contact_desc"].ToString();
}
if (dr["service_desc"] != DBNull.Value)
{
lblReasonforContact.Text = dr["service_desc"].ToString();
}
if (dr["health_screening_recommendations_desc"] != DBNull.Value)
{
lblReasonforContact.Text = dr["health_screening_recommendations_desc"].ToString();
}
}
Label lblServiceDeliveryTime = (Label)e.Row.FindControl("lblServiceDeliveryTime");
if (dr["service_delivery_time"] != DBNull.Value)
lblServiceDeliveryTime.Text = dr["service_delivery_time_desc"].ToString();
Label lblcreatedby = (Label)e.Row.FindControl("lblcreatedby");
if (dr["createdby"] != DBNull.Value)
lblcreatedby.Text = dr["createdby"].ToString();
Label lblServiceType = (Label)e.Row.FindControl("lblServiceType");
if (lblServiceType != null)
{
if (dr["contact_desc"] != DBNull.Value)
lblServiceType.Text = dr["contact_desc"].ToString();
}
string strScriptParam = "";
string service_id="", psn = "", contact = "", reason = "", outcome = "", servicetraveltime = "", settingtype = "", strOtherTypeOfSetting = "";
string dtmonth = "", dtday = "", dtyear = "", createby = "", note = "";
string dtservicemonth = "", dtserviceday = "", dtserviceyear = "", dtfollowupbymonth = "", dtfollowupbyday = "", dtfollowupbyyear = "", service = "", HealthScreening = "", service_completed = "";
if (dr["service_outcome_id"] != DBNull.Value)
service_id = dr["service_outcome_id"].ToString();
if (dr["PSN"] != DBNull.Value)
psn = dr["PSN"].ToString();
if (dr["dtDay"] != DBNull.Value)
dtday = dr["dtDay"].ToString();
if (dr["dtMonth"] != DBNull.Value)
dtmonth = dr["dtMonth"].ToString();
if (dr["dtYear"] != DBNull.Value)
dtyear = dr["dtYear"].ToString();
if (dr["mode_of_contact"] != DBNull.Value)
settingtype = dr["mode_of_contact"].ToString();
if (dr["other_mode_of_contact"] != DBNull.Value)
strOtherTypeOfSetting = dr["other_mode_of_contact"].ToString();
if (dr["contact"] != DBNull.Value)
contact = dr["contact"].ToString();
if (dr["reason_for_contact"] != DBNull.Value)
reason = dr["reason_for_contact"].ToString();
if (dr["outcome"] != DBNull.Value)
outcome = dr["outcome"].ToString().Replace("'", "''");
if (dr["service_delivery_time"] != DBNull.Value)
servicetraveltime = dr["service_delivery_time"].ToString();
if (dr["comment"] != DBNull.Value)
note = dr["comment"].ToString();
if (dr["health_screening_recommendations"] != DBNull.Value)
HealthScreening = dr["health_screening_recommendations"].ToString();
if (dr["service_completed"] != DBNull.Value)
{
service_completed = (string)dr["service_completed"].ToString();
}
if (dr["service_complete_date"] != DBNull.Value)
{
DateTime dtServicedate = (DateTime) dr["service_complete_date"];
dtservicemonth = dtServicedate.Month.ToString();
dtserviceday = dtServicedate.Day.ToString();
dtserviceyear = dtServicedate.Year.ToString();
}
if (dr["followup_by_date"] != DBNull.Value)
{
DateTime dtfollowupdate = (DateTime)dr["followup_by_date"];
dtfollowupbymonth = dtfollowupdate.Month.ToString();
dtfollowupbyday = dtfollowupdate.Day.ToString();
dtfollowupbyyear = dtfollowupdate.Year.ToString();
}
if (dr["service"] != DBNull.Value)
{
service = dr["service"].ToString();
}
strScriptParam = "'" + service_id +
"','" + psn +
"','" + dtmonth +
"','" + dtday +
"','" + dtyear +
"','" + settingtype +
"','" + contact +
"','" + reason +
"','" + servicetraveltime +
"','" + outcome.Replace("'", "Å").Replace(Environment.NewLine, "\\n")+
"','" + note.Replace("'", "Å").Replace(Environment.NewLine, "\\n") +
"','" + strOtherTypeOfSetting.Replace("'", "Å").Replace(Environment.NewLine, "\\n") +
"','" + HealthScreening +
"','" + service_completed +
"','" + dtservicemonth +
"','" + dtserviceday +
"','" + dtserviceyear +
"','" + dtfollowupbymonth +
"','" + dtfollowupbyday +
"','" + dtfollowupbyyear +
"', '" + service + "'";
e.Row.Attributes.Add("style", "cursor:hand");
e.Row.Attributes.Add("onclick", "javascript:return ShowGridRow(" + strScriptParam + ");");
ImageButton lnkDel = (ImageButton)e.Row.FindControl("lnkDel");
if (lnkDel != null)
lnkDel.Attributes.Add("onclick", "javascript:ShowGridRow(" + strScriptParam + "); DeleteService('" + dr["service_outcome_id"].ToString() + "');");
}
}
这是我收到的错误消息:
消息:预期')'
我认为需要更改代码!
"','" + outcome.Replace("'", "Å").Replace(Environment.NewLine, "\\n")+
"','" + note.Replace("'", "Å").Replace(Environment.NewLine, "\\n") +
"','" + strOtherTypeOfSetting.Replace("'", "Å").Replace(Environment.NewLine, "\\n") +
任何帮助表示赞赏。