在我的 RowDataBound 事件中,我想更新行值,但我无法将我的对象转换为 DataRowView。还有另一种方法来更新行列吗?
这就是我所拥有的。它不能将类型 Offer 转换为 DataRowView。
/// <summary>
/// Gridview Row Data Bound
/// </summary>
protected void grdvOffers_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Converts the UTC date to PST timezone
if (e.Row.RowType == DataControlRowType.DataRow)
{
//DataRow row = ((DataRowView)e.Row.DataItem).Row;
Offer row = ((Offer)e.Row.DataItem).Row;
DateTime utcTime = row.Field<DateTime>("Created");
DateTime dtUpdateDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, CFrmFunctions.GetPresetTimeZone());
row.SetField<DateTime>("Created", dtUpdateDateTime);
}
}
<asp:ObjectDataSource ID="objOfferDataSource" runat="server" SelectMethod="GetAllOffers"
TypeName="CancelForms.Repositories.OfferRepo"></asp:ObjectDataSource>