9
我有一個像這樣的gridview。GridView中的CommandArgument
<asp:GridView ID="grdMerchant" runat="server" GridLines="None"
HeaderStyle-Font-Bold="True" AutoGenerateColumns="False" AllowSorting="True" ShowHeader="false" OnRowDataBound="grdMerchant_RowDataBound" OnRowCommand="grdMerchant_RowCommand" DataKeyNames="OrderID" style="table-layout:auto;width:100%;" >
<asp:TemplateField >
<ItemTemplate>
<asp:Linkbutton ID= "btnView" runat="server" Text="View" OnClick="btnView_OnClick" CommandArgument='<%#Eval("OrderID")%>' ></asp:Linkbutton>
我希望如何獲取所選行的訂單ID。我試過使用
int OrderID = (int)grdMerchant.DataKeys[row.RowIndex][2];
但它變得空,我知道這不是方式。幫我。
預先感謝您!