Problems with casting DataGridItem.findcontrol and DataGridItem.cells(0).control(1) to checkbox

Discussion in 'ASP .Net Datagrid Control' started by Samuel Chowdhuri, Oct 18, 2003.

  1. this peace of code is giving me trouble

    DIM i as DataGridItem

    for each i in myDataGrid
    checkbox chkbox = Ctype(i.findcontrol("deletethis"),checkbox)

    if(chkbox.checked) then
    ......
    .....

    Compiler Error: Value of type 'System.Web.UI.Control' cannot be converted to
    'System.Windows.Forms.CheckBox'.


    Alternatively I have tried

    chkbox = Ctype(i.cells(0).control(1),checkbox)
    if(chkbox.checked) then
    ......
    .....

    Compiler Error: Value of type 'System.Web.UI.Control' cannot be converted to
    'System.Windows.Forms.CheckBox'.

    How can I overcome this, i need to be able to see if the checkbox is checked
    in order to delete the respective rows



    Thanx


    Sam
     
    Samuel Chowdhuri, Oct 18, 2003
    #1
    1. Advertising

  2. Samuel Chowdhuri

    Alvin Bruney Guest

    wow, hold on you are trying to convert a WEB control into a WINDOWS control.
    Is that really what you really want to do? Where is checkbox coming from?
    Also what troubles me is that you seem to have two types of controls
    (windows/web) on the same form. Is that by design?

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits/default.htm

    "Samuel Chowdhuri" <> wrote in message
    news:#...
    > this peace of code is giving me trouble
    >
    > DIM i as DataGridItem
    >
    > for each i in myDataGrid
    > checkbox chkbox = Ctype(i.findcontrol("deletethis"),checkbox)
    >
    > if(chkbox.checked) then
    > .....
    > ....
    >
    > Compiler Error: Value of type 'System.Web.UI.Control' cannot be converted

    to
    > 'System.Windows.Forms.CheckBox'.
    >
    >
    > Alternatively I have tried
    >
    > chkbox = Ctype(i.cells(0).control(1),checkbox)
    > if(chkbox.checked) then
    > .....
    > ....
    >
    > Compiler Error: Value of type 'System.Web.UI.Control' cannot be converted

    to
    > 'System.Windows.Forms.CheckBox'.
    >
    > How can I overcome this, i need to be able to see if the checkbox is

    checked
    > in order to delete the respective rows
    >
    >
    >
    > Thanx
    >
    >
    > Sam
    >
    >
     
    Alvin Bruney, Oct 20, 2003
    #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. Martin Eyles

    Page.FindControl type casting

    Martin Eyles, Sep 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,560
    Martin Eyles
    Sep 15, 2005
  2. Edwin Knoppert

    Gridview's findcontrol ignores cells()

    Edwin Knoppert, Nov 25, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,559
    Edwin Knoppert
    Nov 25, 2005
  3. John Smith

    DataGridItem.FindControl()

    John Smith, Jun 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    589
    John Smith
    Jun 6, 2006
  4. John Smith

    DataGridItem.FindControl() (REPOST)

    John Smith, Jun 7, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,626
    vMike
    Jun 7, 2006
  5. Alan Z. Scharf

    Casting DataGridItem

    Alan Z. Scharf, Jul 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    152
    Alan Z. Scharf
    Jul 12, 2005
Loading...

Share This Page