ASP.NET Gridview: How Can We Find Which Column Was Selected In Gridview
Solution 1:
I found the solution for my problem which is as follow:
We have to cancel the Event Bubbling from Checkbox so that it won't bubble up to the Gridview RowClicked event.
The way of canceling the event bubbling form checkbox is as follow:
cb.Attributes("onclick") = "event.cancelBubble=true;"
where cb is the checkbox.
Hope this will help others having same problem as i did,
Thanks,
Solution 2:
I'm, not to sure how exactly you add the checkbox to your gridview row but in case you do it server side make sure the AutoPostback property for the (or each) checkbox is set to false. If set to true you'll end up with a postback as soon as somebody checks/unchecks one of your checkboxes.
Solution 3:
We can add checkbox in our gridview, below is a sample code that we need inside Columns of GridView:
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkBxSelect" runat="server" AutoPostBack ="false" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
<HeaderTemplate>
<asp:CheckBox ID="chkBxHeader" onclick="javascript:HeaderClick(this);" runat="server" />
</HeaderTemplate>
Is it possible in ASP.NET Gridview the we postback if we click in some columns of Gridview and we don't postback when we click in certain selected columns.
e.g. I have 3 columns in a gridview, I want to postback if i click in column 1 and 2 and don't want postback if i click in column 3.
Post a Comment for "ASP.NET Gridview: How Can We Find Which Column Was Selected In Gridview"