Checkbox in a grid
-
If we have a checkbox in a grid when we check the the checkbox a javascript function will be called and if we uncheck the same checkbox another javascript will be called.How is it possible...Its Urgent
-
If we have a checkbox in a grid when we check the the checkbox a javascript function will be called and if we uncheck the same checkbox another javascript will be called.How is it possible...Its Urgent
http://www.google.com/search?source=ig&hl=en&rlz=&q=Datagrid+with+checkbox&btnG=Google+Search[^]
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
If we have a checkbox in a grid when we check the the checkbox a javascript function will be called and if we uncheck the same checkbox another javascript will be called.How is it possible...Its Urgent
-
If we have a checkbox in a grid when we check the the checkbox a javascript function will be called and if we uncheck the same checkbox another javascript will be called.How is it possible...Its Urgent
Hey, try this.. Javascript function
var chkT; function Test(chkT) { alert(chkT.checked); }
Add template filed. In that add checkbox and then find control in RowDataBound event of Gridview. Code behind file.try { CheckBox chk = (CheckBox)e.Row.Cells[6].FindControl("chkTest"); chk.Attributes.Add("onclick", "javascript:Test(this);"); } catch(Exception ex) { }
See whats happening...Thanks, Sun Rays To get something you must have to try once. My Articles
-
Hey, try this.. Javascript function
var chkT; function Test(chkT) { alert(chkT.checked); }
Add template filed. In that add checkbox and then find control in RowDataBound event of Gridview. Code behind file.try { CheckBox chk = (CheckBox)e.Row.Cells[6].FindControl("chkTest"); chk.Attributes.Add("onclick", "javascript:Test(this);"); } catch(Exception ex) { }
See whats happening...Thanks, Sun Rays To get something you must have to try once. My Articles
Thanks for ur kind reply. I tried like that and i got the click event ,but the pbm is when i uncheck the checkbox i want to call another javascript function.
-
Thanks for ur kind reply. I tried like that and i got the click event ,but the pbm is when i uncheck the checkbox i want to call another javascript function.
Hi, when you will uncheck you will get item.checked = false. so you can write if condition.
if(item.checked == true) { //call here Checked function } else { //call here Unchecked function }
Hope it will help youThanks, Sun Rays To get something you must have to try once. My Articles
-
If we have a checkbox in a grid when we check the the checkbox a javascript function will be called and if we uncheck the same checkbox another javascript will be called.How is it possible...Its Urgent
Hi This could help.
function select_deselectAll (chkVal, idVal) { var frm = document.forms[0]; // Loop through all elements for (i=0;i< frm.length; i++) { // Look for our Header Template's Checkbox if (idVal.indexOf ('CheckAll') != -1) { // Check if main checkbox is checked, then select or deselect datagrid checkboxes if(chkVal == true) { frm.elements[i].checked = true; } else { frm.elements[i].checked = false; } // Work here with the Item Template's multiple checkboxes } else if (idVal.indexOf ('DeleteThis') != -1) { // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox if (frm.elements[i].checked == false) { frm.elements[1].checked = false; //Uncheck main select all checkbox } } } } function confirmDelete (frm) { // loop through all elements for (i=0; i { // Look for our checkboxes only if (frm.elements[i].name.indexOf("DeleteThis") !=-1) { // If any are checked then confirm alert, otherwise nothing happens if(frm.elements[i].checked) { return confirm ('Are you sure you want to delete your selection(s)?') } } } } CellPadding="3" CellSpacing="0" Font-Size="9pt" AutoGenerateColumns="False" HeaderStyle-BackColor="darkred" HeaderStyle-ForeColor="white"> < Columns> < asp:TemplateColumn> < HeaderTemplate> < asp:CheckBox ID="CheckAll" OnCheckedChanged="javascript: return select_deselectAll (this.checked,this.id);" runat="server" /> < font face="Webdings" color="white" size="4">< /font> < /HeaderTemplate> < ItemTemplate> < asp:CheckBox ID="DeleteThis" OnCheckedChanged="javascript: return select_deselectAll (this.checked, this.id);" runat="server" /> < /ItemTemplate> < /asp:TemplateColumn> < asp:TemplateColumn> < HeaderTemplate> ID < /HeaderTemplate> < ItemTemplate> < asp:Label ID="StoreID" Text='< %# DataBinder.Eval (Container.DataItem, "ID") %>' runat="server"/> < /ItemTemplate> < /asp:TemplateColumn> < asp:BoundColumn HeaderText="Store" Datafield="Store" runat="server" /> < asp:BoundColumn HeaderText="Address" Datafield="Address" runat="server" /> < asp:BoundColumn HeaderText="City" Datafield="City" runat="server" /> <
-
Hi, when you will uncheck you will get item.checked = false. so you can write if condition.
if(item.checked == true) { //call here Checked function } else { //call here Unchecked function }
Hope it will help youThanks, Sun Rays To get something you must have to try once. My Articles
CheckBox ch = (CheckBox)e.Row.Cells[1].FindControl("ChkEdit"); if (ch.Checked == true) { ch.Attributes.Add("onclick", "javascript:Del(this);"); } else ch.Attributes.Add("onclick", "javascript:BtnAdd_onClick(this);"); I given like that but i wont work
-
CheckBox ch = (CheckBox)e.Row.Cells[1].FindControl("ChkEdit"); if (ch.Checked == true) { ch.Attributes.Add("onclick", "javascript:Del(this);"); } else ch.Attributes.Add("onclick", "javascript:BtnAdd_onClick(this);"); I given like that but i wont work
Hey, u have mistaken.. Not here.. In Javascript write function... Call only a single function from codebehind... But make difference in Javascript... Got it ? :)
Thanks, Sun Rays To get something you must have to try once. My Articles
-
Hey, u have mistaken.. Not here.. In Javascript write function... Call only a single function from codebehind... But make difference in Javascript... Got it ? :)
Thanks, Sun Rays To get something you must have to try once. My Articles
Is it possible to call 2 javascript function on a checkbox in a grid on onclick event.one is onclick="return Select(this);" .if possible to call another javascript function on the same onclick event..