ASP.NET DataRowView在GridView和DataList的用法

摘要:DataRowView在GridView和DataList的用法

GridView裡面的用法:

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    DataRowView dv = (DataRowView)e.Row.DataItem;
    Response.Write(dv["title"]);
    }
    }


DataList的用法:

   protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
    {
    DataRowView dv = (DataRowView)e.Item.DataItem;
    Response.Write(dv["title"]+"
");
    }
    }