<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中,但它仍然会立即消失