我有一个填充数据网格视图的函数,此函数使用分页
page size = 30
public static void FillDataGrid(DataGridView dataGrid, int intPageSize, int intPageIndex, out int intTotal
,string title)
{
dataGrid.Rows.Clear();
try
{
var dt = GetData(intPageSize, intPageIndex, out intTotal, title); //dt type DataTable
var dicrectory = Directory.GetCurrentDirectory();
for (var i = 0; i < dt.Rows.Count; i++)
{
var uri = new Uri(dt.Rows[i]["URL"].ToString());
var host = uri.Host.Replace("www.", "");
host = host.Replace(".com", "");
var iconFullUrl = dicrectory + @"\Icons\" +
dt.Rows[i]["IconURL"].ToString();
object[] row = new object[10];
row[0] = "False";
row[1] = Image.FromFile(iconFullUrl);
row[2] = dt.Rows[i]["Title"].ToString();
row[3] = host;
row[4] = Convert.ToDateTime(dt.Rows[i]["Date"].ToString()).ToShortDateString();
row[5] = "";
row[6] = dt.Rows[i]["URL"].ToString();
row[7] = "";
row[8] = "";
row[9] = dt.Rows[i]["Id"].ToString();
dataGrid.Rows.Add(row);
}
}
catch (Exception ex)
{
throw ex;
}
}
在此部分代码中发生错误 的
row[1] = Image.FromFile(iconFullUrl);
答案 0 :(得分:2)