Grid view check box should check one by one [Resolved]

Posted by Sthsyed under ASP.NET on 9/27/2016 | Points: 10 | Views : 1368 | Status : [Member] | Replies : 1
I have a grid view of items which is sorted by purchased date descending where i can select items by checking check box one by one from top to bottom.

My objective is to force the user to check the first line and then second one (not random)

Help me in this regard.

Hope i explained if any details will be provided.




Responses

Posted by: Rajnilari2015 on: 10/12/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this

javascript
-------------

<script type="text/javascript">
function isCheck(element) {
var gv = document.getElementById("<%=grdTest.ClientID%>");
var chk = gv.getElementsByTagName("input");
var row = element.parentNode.parentNode;
for (var i = 0; i < chk.length; i++) {
if (chk[i].type == "checkbox") {
if (chk[i].checked && chk[i] != rb) {
chk[i].checked = false;
break;
}
}
}
}
</script>


aspx/html
------

<asp:GridView ID="grdTest" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField HeaderText ="Purchased Date">
<ItemTemplate>
<asp:CheckBox ID="chkPurchasedDt" AutoPostBack="true" runat="server" onclick="isCheck(this);" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


--
Thanks & Regards,
RNA Team

Sthsyed, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response