-1
protected void ReadHtmlTable(string patientName, string startHour, string startMinute, int rowspan)
            {
                 for(int i = 0; i <= tableAppointment.Rows.Count - 1; i++)
                    {
                        for(int j = 0; j <= tableAppointment.Rows[i].Cells.Count - 1; j++)
                        {
                            if(tableAppointment.Rows[i].Cells[j].InnerHtml.Trim() == startHour)
                            {
                                if(tableAppointment.Rows[i].Cells[j + 1].InnerHtml.Trim()== startMinute)
                                {
                                    tableAppointment.Rows[i].Cells[j + 2].InnerText = patientName;
                                    tableAppointment.Rows[i].Cells[j + 2].RowSpan = rowspan;
                                    tableAppointment.Rows[i].Cells[j + 2].Style.Add("color", "green");
                                    tableAppointment.Rows[i].Cells[j + 2].Style.Add("background", "green");
                                }
                            }
                        }
                    }
        }

Above code is my server side code which executes on OnSaveStateComplete(EventArgs e) event . i am reading my html table in c#. when i check its first cell second cell text then its give result like this "\r\n\t\t\t\t\t\t\t\t\t08:00\r\n\t\t\t\t\t\t\t\t" .I have use trim at end but not work.

4

2 回答 2

0

尝试这个

string str = "\r\n\t\t\t\t\t\t\t\t\t08:00\r\n\t\t\t\t\t\t\t\t".Trim('\t', '\r', '\n');
于 2012-06-30T10:43:24.460 回答
0

您应该可以使用 RegEx 将其从那里 RegEx.Replace(tableAppointment.Rows[i].Cells[j + 1].InnerHtml, "\\s+", "");

MSDN上的 Regex.Replace 方法。那里的例子也处理了空白。

于 2012-06-30T10:54:15.413 回答