<script type="text/javascript">
function foo(Id, Index, obj) {
if (obj.checked) {
alert(Id); //"Id" field
alert(Index); //Row Index (1-based)
window.open('addmaster.aspx', '', 'left=25%, top=25%, width=800px, height=670px, scrollbars=no, status=no, resizable=no');
}
}
</script>
I guess you dont want the alerts to be shown and want to use it as querystring for addmaster.aspx. In that case comment out the alerts and use it to pass it as querystring...then those alerts would not appear.
function foo(Id, Index, obj) {
if (obj.checked) {
// alert(Id); //"Id" field
// alert(Index); //Row Index (1-based)
window.open('addmaster.aspx?id=' + Id + '&index=' + Index, '', 'left=25%, top=25%, width=1002px, height=650px, scrollbars=no, status=no, resizable=no');
}
}
And in case you need every checked checkbox's associated id, you can use the logic below:
function foo(Id, Index, obj) {
var ids = '';
if (obj.checked) {
for (i = 0; i < document.forms[0].elements.length; i++) {
ele = document.forms[0].elements[i];
if ((ele.type == "checkbox") && (ele.checked == true)) {
ids += ele.value + ",";
}
}
alert(ids.substr(0, ids.length - 1)); //comman separated id of every checked checkbox
}
}
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="select">
<ItemTemplate>
<input id="chkSelect" type="checkbox" onclick='<%# "foo(\"" + Eval("Id").ToString() + "\",\"" + (Container.DataItemIndex + 1) + "\",this);"%>'
value='<%#Eval("Name").ToString() %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" />
</Columns>
</asp:GridView>
thanks a lot me_ritz sir,as far as my problem is concerned its 96% resolved(i am getting my new window),the only problem i am facing is instead of associated checked checkbox id,i am getting "on","on".in place of id its displaying "on" seperated by comma
onclicking other checkboxlist..a pop-up dialog box is shown showing "on",on,on...the more the checkbox i checked the more i get on separated by comma.
me_ritz
Star
9337 Points
1447 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 12:08 PM|LINK
I guess you dont want the alerts to be shown and want to use it as querystring for addmaster.aspx. In that case comment out the alerts and use it to pass it as querystring...then those alerts would not appear.
function foo(Id, Index, obj) { if (obj.checked) { // alert(Id); //"Id" field // alert(Index); //Row Index (1-based) window.open('addmaster.aspx?id=' + Id + '&index=' + Index, '', 'left=25%, top=25%, width=1002px, height=650px, scrollbars=no, status=no, resizable=no'); } }And in case you need every checked checkbox's associated id, you can use the logic below:
function foo(Id, Index, obj) { var ids = ''; if (obj.checked) { for (i = 0; i < document.forms[0].elements.length; i++) { ele = document.forms[0].elements[i]; if ((ele.type == "checkbox") && (ele.checked == true)) { ids += ele.value + ","; } } alert(ids.substr(0, ids.length - 1)); //comman separated id of every checked checkbox } } <asp:GridView ID="gv" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="select"> <ItemTemplate> <input id="chkSelect" type="checkbox" onclick='<%# "foo(\"" + Eval("Id").ToString() + "\",\"" + (Container.DataItemIndex + 1) + "\",this);"%>' value='<%#Eval("Name").ToString() %>' /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="Name" /> </Columns> </asp:GridView>Thanks
Rounak Rana
Member
48 Points
237 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 02:49 PM|LINK
thanks a lot me_ritz sir,as far as my problem is concerned its 96% resolved(i am getting my new window),the only problem i am facing is instead of associated checked checkbox id,i am getting "on","on".in place of id its displaying "on" seperated by comma onclicking other checkboxlist..a pop-up dialog box is shown showing "on",on,on...the more the checkbox i checked the more i get on separated by comma.