小弟在學習中有一問題,就是合併兩列相同信息行,其中第二列要求在第一列有相同信息行和第二列有相同信息行的情況下才合併,謝謝!
------解决方案--------------------------------------------------------
一段大致的伪代码:
int id_rowspan=1;
int name_rowspan=1;
string strID= " ";
string strName= " ";
object last_id_td=null;
object last_name_td=null;
resonse.write( " <table> ");
for (int i=0;i <dt.rows.count;++i)
{
if (dt[i][ "ID "]==strID)
{
id_rowspan++;
if (dt[i][ "Name "]==strName)
{
name_rowspan++;
}
else
{
if (lst_name_td!=null)
{
lst_name_td.attributes.add( "rowspan ",name_rowspan.tostring());
}
strName=dt[i][ "Name "];
name_rowspan=1;
lst_name_td=...;
}
}
else
{
if (lst_id_td!=null)
{
lst_id_td.attributes.add( "rowspan ",id_rowspan.tostring())
}
strID=dt[i][ "ID "];
strName=dt[i][ "Name "];
id_rowspan=1;
name_rowspan=1;
lst_id_td=...;
lst_name_td=...;
}
....
}
resonse.write( " </table> ");