如何将工作表名称检索到下拉列表中

时间:2014-02-07 13:16:03

标签: asp.net c#-4.0

DataTable dtExcelSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string getExcelSheetName = dtExcelSheetName.Rows[0]["Table_Name"].ToString();

cmd.CommandText = "SELECT * FROM [" + getExcelSheetName + "]";

ArrayList aList = new ArrayList();



foreach (DataRow row in dtExcelSheetName.Rows)
{
    aList.Add(row);
}       
drpSeletSheet.DataSource = aList;
for (int i = 1; i < dtExcelRecords.Rows.Count + 1; i++)
{
    drpSeletSheet.Items.Add(dtExcelRecords.Rows[i]["Table_Name"].ToString());
}
drpSeletSheet.DataBind();

objAdapter1.SelectCommand = cmd;
objAdapter1.Fill(dtExcelRecords);

0 个答案:

没有答案