我有带ButtonField的GridView:
<asp:GridView ID="activitygrid" runat="server" CssClass="EU_DataTable" class="ui-body-d" OnRowCommand="activitygrid_RowCommand1" AutoGenerateColumns="False" OnSelectedIndexChanged="activitygrid_SelectedIndexChanged" ShowHeaderWhenEmpty="True" >
<asp:ButtonField CommandName="cmdRegister" Text="register now" ControlStyle-CssClass="table-stripe" HeaderText="register" ButtonType="Button" ControlStyle-Height="20px" >
<ControlStyle CssClass="table-stripe"></ControlStyle>
</asp:ButtonField>
页面加载代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
else
{
BindDataSecondTime();
}
}
RowCommand代码:
protected void activitygrid_RowCommand1(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "cmdRegister")
{
registerActivities.Add(relActivities[index]);
//Update the sum
CurrentSum += relActivities[index].ActivityPrice;
lblSum.Text = CurrentSum.ToString();
selectedactivitygrid.DataSource = registerActivities;
selectedactivitygrid.DataBind();
relActivities.Remove(relActivities[index]);
activitygrid.DataSource = relActivities;
activitygrid.DataBind();
}
}
问题是当我点击按钮时有时会触发事件(通常是当我点击按钮中间时),有时候没有。
请帮忙。
答案 0 :(得分:0)
我删除ControlStyle-Height="20px"
并解决了问题。