1
我有一个Gridview
有一个下拉和按钮。现在我想获得选定的button click
。这里是dropdown
列表的价值是我的示例代码访问下拉菜单中选择的项目
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="ddPStatud" runat="server" DataSourceID="sdsProductStatus" DataTextField="StatusName"
DataValueField="StatusId">
</asp:DropDownList>
<asp:SqlDataSource ID="sdsProductStatus" runat="server" ConnectionString="<%$ ConnectionStrings:cs %>"
SelectCommand="SelectProductStatus" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="Branchid" SessionField="Branchid" Type="Int16" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
,这里是按钮
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="tst" runat="server" Text="text" CommandName="Test" CommandArgument='<%# Eval("EntryID") %>'/>
</ItemTemplate>
</asp:TemplateField>
,这是RowCommand
功能
if (e.CommandName == "Test")
{
String row = e.CommandArgument.ToString();
lblError.Visible = true;
lblError.Text = row;}