【问题标题】:Detailsview Edit and Insert using DatabindDetailsview 使用 Databind 编辑和插入
【发布时间】:2013-11-10 06:05:15
【问题描述】:

我有一个 Detailsview,我使用数据集作为 Detailsview 的数据源,我想使用 Dataset 作为数据源在 detailsview 上使用 Edit/Insert,如果我使用 SqlDataSource 很容易,但不是我的选择。

谢谢

代码如下:

sqlcmd = new SqlCommand("Select *From Category", con);
            adapter = new SqlDataAdapter(sqlcmd);
            DataSet ds = new DataSet();
            con.Open();
            adapter.Fill(ds, "Category");


            DetailsV.DataSource = ds;
            DetailsV.DataBind();
            con.Close();

【问题讨论】:

    标签: data-binding dataset detailsview


    【解决方案1】:

    你可以试试下面的方法:

    System.Data.DataSet ds = ...;
    DetailsView dv = ...;
    dv.DataSource = ds.Tables[0];
    

    【讨论】:

    • 知道了,先生,但我的问题是如何应用 Detailsview EDIT/DELETE/INSERT 当 detailsview 数据源来自 DATASET 并且 detailsview 属性的 autogeneratecolumns = true 时,这意味着 detailsview 的数据是动态生成的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-22
    • 2015-07-03
    • 2012-03-06
    • 1970-01-01
    相关资源
    最近更新 更多