0

看到此错误时我需要做什么:(DataSource 和 DataSourceID 都在“DataLista”上定义。删除一个定义。)

我的代码如下:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {string path = Server.MapPath(".") + "\\upload\\";
    string[] list = System.IO.Directory.GetFiles(path);     
        var listone = from filename in System.IO.Directory.GetFiles(path) select string.Format("upload/{0}", System.IO.Path.GetFileName(filename));     
        DataLista.DataSource = listone;
        DataLista.DataBind();//This line gives error
    }
}
4

1 回答 1

1

从 aspx 中删除 DataSourceID。

如果您使用 SqlDataSource 或 ObjectDataSource 控件进行绑定,则仅使用 DataSourceID。

于 2013-10-09T15:47:23.910 回答