我正在实现收件箱的功能,我有一个GridView和代码如下:
<asp:GridView Width="100%" ID="grdInbox" AutoGenerateColumns="false" AllowPaging="true"
runat="server" onrowcommand="grdInbox_RowCommand" GridLines="None" CssClass="mGrid"
PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
onrowdatabound="grdInbox_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="mailSelector" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Sender" HeaderText="Sender" SortExpression="Sender" />
<asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" />
<asp:BoundField DataField="Size" HeaderText="Size" />
<asp:BoundField DataField="Sent" HeaderText="Sent at" SortExpression="Sent" />
</Columns>
</asp:GridView>
此外,我已注册“onclick”事件如下:
e.Row.Attributes["onclick"] = "location.href='MailContent.aspx?id=" + e.Row.UniqueID + "'";
但即使我选择了一个复选框onclick事件也会被触发。我不希望复选框触发此事件。它应该只用于选择行。我该怎么办?