[Asp.Net] 學習筆記CommandArgument
ASP中用Button傳遞兩個職給後台的方法: 1、在CommandArgument中用逗號分隔要傳送到後台的兩個參數: <asp:GridView ID="GridViewUserScraps" ItemStyle-VerticalAlign="Top" AutoGenerateColumns="False" Width="100%" runat="server" OnRowCommand="GridViews_RowCommand" > <Columns> <asp:TemplateField SortExpression="SendDate"> <ItemTemplate> <asp:Button ID="btnPost" CssClass="submitButton" Text="Comment" runat="server" CommandName="Comment" CommandArgument='<%#Eval("ID")+","+ Eval("UserID")%>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> p.s. 也可以用這種 CommandArgument='<%# DataBinder.Eval(Container.DataItem,"ID") + "," + DataBinder.Eval(Container.DataItem,"UserID")%>' 2、C#後台接收到button傳遞的參數後的處理方法: protected void GridView...