62,017
社区成员
发帖
与我相关
我的任务
分享
protected void xx_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Del")
{
GridViewRow drv = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
DropDownList dp = xx.Rows[drv.RowIndex].FindControl("dpOK") as DropDownList;
int value = 0;
if (dp != null)
value = Convert.ToInt32(dp.SelectedValue);//value=2;
}
}
<asp:GridView ID="xx" runat="server" OnRowCommand="xx_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="dpOK" runat="server">
<asp:ListItem Selected="True" Text="xxx" Value="2"></asp:ListItem>
<asp:ListItem Text="xxx1" Value="3"></asp:ListItem>
<asp:ListItem Text="xxx2" Value="4"></asp:ListItem>
</asp:DropDownList>
<asp:LinkButton ID="btnDel" runat="server" Text="删除" CommandName="Del"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>