日期:2014-05-19  浏览次数:20406 次

拆分字符串的问题
数据库有例如 "城东,租房 "这样的记录,如何把它拆分出来,并逐个显示出来??且每个标签都能链接到相应的记录列表.如: <a   href= "Search.aspx?K= "城东 "> 城东 </a> "我不想用Repeater里套用DataList来实现..

------解决方案--------------------
split到数组或者集合中,然后循环输出
------解决方案--------------------
string[] strArr = str.split( ', ');

------解决方案--------------------
string old = @ "城东,租房 ";
string[] new = old.Split(new char[] { ', '});
foreach(string str in new)
Reponse.Write( " <a href= "Search.aspx?K=\ " " + str + "\ "> " + str + " </a> ";

------解决方案--------------------
string abc = "城东,租房 ";
string ddd = abc.Substring(0,2);
string href = " <a href= 'WebForm2.aspx?K= " + ddd + " '> " + ddd + " </a> ";
Response.Write(href);
------解决方案--------------------
string old = @ "城东,租房 ";
string[] new = old.Split(new char[] { ', '});
foreach(string str in new)
Reponse.Write( " <a href= "Search.aspx?K=\ " " + str + "\ "> " + str + " </a> ";
------解决方案--------------------
用split 函数 与循环语句
动态输出html语句