<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="500px" AutoGenerateRows="False"
DataKeyNames="strPositionId,nFolderId,tmVaRPosition,fP18VaR" DataSourceID="ODSManualPosVaR"
OnItemInserted="DetailsView1_ItemInserted" OnItemInserting="DetailsView1_ItemInserting" DefaultMode="Insert"
SkinID="detailsviewSkin" EnableModelValidation="True" OnDataBound="DetailsView1_DataBound">
<HeaderStyle Width="200px" />
<FieldHeaderStyle Width="200px" />
<Fields>
<asp:BoundField DataField="strPositionId" HeaderText="Id" ItemStyle-Width="200" SortExpression="strPositionId" runat="server"/>
</Fields>
</asp:DetailsView>
我想在 ItemInserted 方法中获取该 asp:BoundField 的值:
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
var getBoundFieldValue = ?
DetailsView1.DataBind();
}
我相信这是正确的方法:
DetailsView1.Rows[0].Cells[1].Text;
但是该值消失了(因此它只是一个空字符串)。我试过把这条线放在 Page_Load 中,但它仍然会立即消失