how to delete a row in DataGrid

N

Nandini

I have to delete a row in Datagrid by selecting the checkbox.

And also to select all checkboxes when we select "select" option for
checkboxes.

I kept this below code........but it's giving error ...


<script>
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.checked = true;
}
else
{
frm.elements.checked = false;
}
// Work here with the Item Template's multiple checkboxes
}
else if (idVal.indexOf ('chkSelect') != -1)
{
// Check if any of the checkboxes are not checked, and then
uncheck top select all checkbox
if(frm.elements.checked == false)
{
frm.elements[1].checked = false; //Uncheck main select all
checkbox
}
}
}

}
</script>

I also have:
<asp:TemplateColumn Visible="False">
<HeaderTemplate>
<asp:CheckBox ID="CheckAll" OnClick="javascript: return
select_deselectAll (this.checked, this.id);"
runat="server" />
<font face="Webdings" color="white" size="4">a</font>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="chkSelect" OnClick="javascript: return
select_deselectAll (this.checked, this.id);" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

I get the underlined error for the OnClick event which says that there is no
attribute of OnClick for checkboxes, the page does run, but no selection of
checkboxes happens. If I change OnClick to OnCheckedChanged, the page fails
to load saying that javascript is not a memeber of ASP.Webform1_aspx.

What is the reason for failure here?

Thank you all.
Nandini.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top