how to delete a row in DataGrid

Discussion in 'ASP .Net Datagrid Control' started by Nandini, Oct 21, 2004.

  1. Nandini

    Nandini Guest

    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.
     
    Nandini, Oct 21, 2004
    #1
    1. Advertising

  2. Nandini

    irene Guest

    Nandini,

    Check the following link for your solution:

    http://www.datagridgirl.com/rowselector.aspx

    Irene

    "Nandini" <> wrote in message news:<>...
    > 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.
     
    irene, Oct 27, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    1
    Views:
    1,787
    Rick Spiewak
    Apr 24, 2004
  2. JenHu
    Replies:
    6
    Views:
    5,242
    =?Utf-8?B?UGF1bCBK?=
    Feb 3, 2005
  3. =?Utf-8?B?U2hhd24=?=

    Magic Trick Datagrid Delete Row

    =?Utf-8?B?U2hhd24=?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,476
    =?Utf-8?B?U2hhd24=?=
    Apr 6, 2005
  4. Fred Zolar
    Replies:
    0
    Views:
    225
    Fred Zolar
    Apr 1, 2004
  5. D
    Replies:
    0
    Views:
    230
Loading...

Share This Page