我正在一个需要的网站上遇到麻烦。
gridview数据通过对象数据源
<asp:GridView ID="Booking_GridView" runat="server" AutoGenerateColumns="False" AllowPaging="true" PageSize="20" AllowSorting="true"
DataSourceID="Project_ObjectDataSource" CssClass="Booking_Overview" GridLines="None" DataKeyField="No">
<Columns>
<asp:BoundField DataField="External_Document_No" HeaderText="Reference" ReadOnly="True" SortExpression="External_Document_No"/>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="DetailsButton" Text="booking details" runat="server" OnClick="DetailsButton_Click"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="Project_ObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="List" TypeName="uWeb.Data.Project">
<SelectParameters>
<asp:Parameter Name="SearchStr" DefaultValue="" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
点击#DetailsButton时:
protected void DetailsButton_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridViewRow gvr = (GridViewRow)btn.NamingContainer;
Job j = (Job)gvr.DataItem;
Response.Write("<script>alert('"+j.No +"');</script>");
}
问题是dataitem为空。所以不确定如何继续吗?
然后将该Job对象以某种方式传递给另一个Web表单?