62,272
社区成员
发帖
与我相关
我的任务
分享
DataSet st = photomanage.GetPhotoList();//有11条记录文件夹名称数据
DataSet ds=null;
for (int i = 0; i<st.Tables[0].Rows.Count;i++)
{
string path = Server.MapPath("\\Files\\Photo\\") + st.Tables[0].Rows[i]["photoname"].ToString();
int StartIndex = CurrentPage * PageSize;
DirectoryInfo imagesfile = new DirectoryInfo(path);
FileInfo[] Sfi = imagesfile.GetFiles(); //获得文件信息
//通过hashtable绑定路径
ds= new DataSet();
DataTable tb = new DataTable();
ds.Tables.Add(tb);
DataColumn colSmall = new DataColumn("SmallPhoto");
DataColumn colName = new DataColumn("Name");
ds.Tables[0].Columns.Add(colSmall);
ds.Tables[0].Columns.Add(colName);
if (Sfi.Length == 0)
{
DataRow row = ds.Tables[0].NewRow();
row["SmallPhoto"] = "../Images/fm.jpg";
row["Name"] = st.Tables[0].Rows[i]["photoname"].ToString();
ds.Tables[0].Rows.Add(row);
}
if (Sfi.Length - StartIndex < 12)
{
for (int j = 0; j < (Sfi.Length - StartIndex); j++)
{
DataRow row = ds.Tables[0].NewRow();
row["SmallPhoto"] = "../../Files/photo/" + Sfi[j + StartIndex].Name;
row["Name"] = Sfi[j + StartIndex].Name;
ds.Tables[0].Rows.Add(row);
}
}
else
{
for (int k = 0; k < PageSize; k++)
{
DataRow row = ds.Tables[0].NewRow();
row["SmallPhoto"] = "../../Files/photo/" + Sfi[k + StartIndex].Name;
row["Name"] = Sfi[k + StartIndex].Name;
ds.Tables[0].Rows.Add(row);
}
}
}
return ds; //此处只返回了一条数据,这是为什么?

DataTable dtsourcetemp = dt.Clone();
for (int i =0; i < pager.PageSize ; i++)
{
if (i == pager.RecordCount)
{
break;
}
dtsourcetemp.Rows.Add(dtsource.Rows[i].ItemArray);
}
DataSet st = photomanage.GetPhotoList();
DataSet ds = new DataSet(); ;
for (int i = 0; i<st.Tables[0].Rows.Count;i++)
{
string path = Server.MapPath("\\Files\\Photo\\") + st.Tables[0].Rows[i]["photoname"].ToString();
int StartIndex = CurrentPage * PageSize;
DirectoryInfo imagesfile = new DirectoryInfo(path);
FileInfo[] Sfi = imagesfile.GetFiles(); //获得文件信息
//通过hashtable绑定小图路径和大图路径
DataTable tb = new DataTable();
DataColumn colSmall = new DataColumn("SmallPhoto");
DataColumn colName = new DataColumn("Name");
tb.Columns.Add(colSmall);
tb.Columns.Add(colName);
if (Sfi.Length == 0)
{
DataRow row = tb.NewRow();
row["SmallPhoto"] = "../Images/fm.jpg";
row["Name"] = st.Tables[0].Rows[i]["photoname"].ToString();
tb.Rows.Add(row);
}
ds.Tables.Add(tb);
}
return ds;