Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# cells.InnerHtml无法以正确的方式运行 protectedvoid ReadHtmlTable(字符串patientName、字符串startHour、字符串startMinute、int rowspan) { 对于(int i=0;i_C#_Asp.net - Fatal编程技术网

C# cells.InnerHtml无法以正确的方式运行 protectedvoid ReadHtmlTable(字符串patientName、字符串startHour、字符串startMinute、int rowspan) { 对于(int i=0;i

C# cells.InnerHtml无法以正确的方式运行 protectedvoid ReadHtmlTable(字符串patientName、字符串startHour、字符串startMinute、int rowspan) { 对于(int i=0;i,c#,asp.net,C#,Asp.net,请尝试此操作 protected void ReadHtmlTable(string patientName, string startHour, string startMinute, int rowspan) { for(int i = 0; i <= tableAppointment.Rows.Count - 1; i++) { for(i

请尝试此操作

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");
                                }
                            }
                        }
                    }
        }

你应该可以用正则表达式将它从那里释放出来
RegEx.Replace(tableAppointment.Rows[i].Cells[j+1].InnerHtml,“\\s+”,”);


位于的Regex.Replace方法。该示例还处理空白。

将InnerHtml.Trim()替换为InnerText.Trim()。我想您应该使用类似“
”的内容,而不是“\r\n”那里。08:00您是否跟踪查看了推荐的替换或修剪功能前后的插入和结果?您是否可以控制HTML表,最好不要在单元格内输入太多选项卡等。更多信息,我相信我们可以与您一起解决。我们都已经假设\r\t等是换行信息-字符串是否实际与转义序列一起返回,例如“\\r\\n\\t”等或转义序列。因为这需要不同的方法(在本例中为模式)@John我没有否决你的问题,你可能想检查一下你的信息。也许你需要更多的信息,我们可以提供帮助。
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');