让Literal1显示信息也能像gridview一样矩阵排列
protected string jigou()
{
string sqlcomm = "";
SqlConnection myconn = DB.mychinaedp();
string strContent = "";
myconn.Open();
int i = 0;
//记录每行多少条新闻
int zong = 20;
//定义总字数
int number = 0;
//要添加空格的数量
string kongge = "";
//空格累加
SqlCommand mycomm = new SqlCommand(sqlcomm, myconn);
SqlDataReader sdr = mycomm.ExecuteReader();
while (sdr.Read())
{
i ++;
number = zong - sdr["newstitle"].ToString().Length;
for (int y = 0; y < number; y++)
{
kongge += " ";
}
strContent += "" + sdr["newstitle"].ToString() + "" + kongge;
if (i % 3 == 0) //判断每行显示多少条信息
{
strContent += "<br><br>";
}
kongge = "";
number = 0;
}
sdr.Close();
return strContent;
}
{
string sqlcomm = "";
SqlConnection myconn = DB.mychinaedp();
string strContent = "";
myconn.Open();
int i = 0;
//记录每行多少条新闻
int zong = 20;
//定义总字数
int number = 0;
//要添加空格的数量
string kongge = "";
//空格累加
SqlCommand mycomm = new SqlCommand(sqlcomm, myconn);
SqlDataReader sdr = mycomm.ExecuteReader();
while (sdr.Read())
{
i ++;
number = zong - sdr["newstitle"].ToString().Length;
for (int y = 0; y < number; y++)
{
kongge += " ";
}
strContent += "" + sdr["newstitle"].ToString() + "" + kongge;
if (i % 3 == 0) //判断每行显示多少条信息
{
strContent += "<br><br>";
}
kongge = "";
number = 0;
}
sdr.Close();
return strContent;
}