hi
in my datagrid i display checkboxes i click checkbox and click button it display that selected row.
my problem is user not select any checkbox of datagrid and click button this time it display one message i.e., "Please select Checkbox"
how to provide this type of message.
Thanks.
Loading
DRISHTYPosted May 14, 2010, 9:44 AM
if you are using lable then, in that code just replace below line :
alert('Please check atleaset one checkbox');
with
var objlbl;
objlbl=document.getElementById('Label1');
objlbl.value='Please check atleaset one checkbox';
ajay rajuPosted May 14, 2010, 9:39 AM
Thank u for giving java script code, if u can give any csharp code todo this,
because in my i am not to display alert message boxes, i am taking label in that label only error message is displayed.
Please give a solution/code todo this.
Thanks.
DRISHTYPosted May 14, 2010, 8:05 AM
So try this..
In page_load add below line for your button
btnTest.Attributes.Add("onClick", "return checkCheckboxes()")
-----------------------
Suppose your checkbox column declaration is,
---------------------------------
Add following javascript function in your head tag :function checkCheckboxes()
{
var frm = document.Form1;
var state=false;
for(i=0;i< frm.length;i++)
{
e=frm.elements[i];
//e.name.indexOf('Id') - Id of checkbox contains 'Id'
if(e.type=='checkbox' && e.name.indexOf('Id') != -1)
{
if(e.checked==true)
{
state=true;
}
}
}
if(state==false)
{
alert('Please check atleaset one checkbox');
return false;
}
return true;
}
DRISHTYPosted May 14, 2010, 6:36 AM
On button click call following code,
function CheckCheckboxes()
{
var frm = document.Form1;
var state=false;
for(i=0;i< frm.length;i++)
{
e=frm.elements[i];
//e.name.indexOf('Id') - Id of checkbox contains 'Id'
if(e.type=='checkbox' && e.name.indexOf('Id') != -1)
{
if(e.checked==false)
{
state=true;
}
}
}
if(state==false)
{
alert('Please check atleaset one checkbox');
}
}
ajay rajuPosted May 14, 2010, 4:50 AM
can you please give any sample java script code for doing this.
Thanks.
DRISHTYPosted May 13, 2010, 9:38 AM
In that, you can display alert message based on condition...
CrishPosted May 13, 2010, 9:33 AM
make javascript function datagrid aspx page and called it from datagrid itemdatabound. Take one hidden textbox where you need to save checkbox values using comma separated.
once any checkbox will be clicked that checkbox value save in textbox with comma separated.
when you click on button then check textbox has value or not . If no values in textbox then show error message.
thanks