Declaring the name of a grid

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Declaring the name of a grid

    How can I declare the name of a grid, then use it to bind it to the
    datasource?

    I have 3 grids, each with different id's. dgOne, dgTwo, dgThree. I want to
    be able to do things to each grid. So I need to pass the name of the grid
    to the GetData procedure. What I have done so far:

    arrGridNames(1) = "One"
    arrGridNames(2) = "Two"
    arrGridNames(3) = "Three"

    dg = "dg" & arrGridNames(1)

    so that I come up with dgOne. But of course that is a string, and can't be
    a datagrid, so when I try to bind it, I get the error: public member
    'Datasource" on type 'String' not found.

    How would I do this?




    eagle Guest

  2. Similar Questions and Discussions

    1. Declaring methods
      I'm an old school C++ programmer that switched to CF development years back. Now with AS3 I've decided to branch out and learn Flex3 and AS3. ...
    2. Declaring Web Services in AS
      Hi, I know I can declare/initiate new WS using <mx:WebService> im my MXML code. I was wondering if it's possible to declare these services using...
    3. Declaring variables across frames
      Hey guys, When I use the LoadVars object to submit a form, and I have different variables across four frames (four page form), how do I declare...
    4. Declaring a Variable
      When I "test movie" a long Flash movie whose first three lines are //--- Number of Questions-- var my_totalquestions:Number = 20...
    5. Declaring sub at top or bottom matter?
      Does declaring at the top or the bottom matter? thanks ----------------------------------------- eMail solutions by http://www.swanmail.com
  3. #2

    Default Re: Declaring the name of a grid

    Use the FindControl Method.

    Here is an example of what you could do, I'm typing this straight into the
    email without an IDE, so you'll pardon any syntax errors. :)

    Dim dgTemp As New DataGrid
    dgTemp = CType(Page.FindControl("DataGrid1or2or3"), DataGrid)
    dgTemp.DataSource = dt
    dgTemp.DataBind();


    HTH

    -S.M. Altaf
    [MVP - VB]




    --------------------------------------------------------------------------------
    All that glitters has a high refractive index. [url]www.mendhak.com[/url]
    "eagle" <eagle@yahoo.com> wrote in message
    news:uKJvhrvsFHA.3604@tk2msftngp13.phx.gbl...
    > How can I declare the name of a grid, then use it to bind it to the
    > datasource?
    >
    > I have 3 grids, each with different id's. dgOne, dgTwo, dgThree. I want
    > to be able to do things to each grid. So I need to pass the name of the
    > grid to the GetData procedure. What I have done so far:
    >
    > arrGridNames(1) = "One"
    > arrGridNames(2) = "Two"
    > arrGridNames(3) = "Three"
    >
    > dg = "dg" & arrGridNames(1)
    >
    > so that I come up with dgOne. But of course that is a string, and can't
    > be a datagrid, so when I try to bind it, I get the error: public member
    > 'Datasource" on type 'String' not found.
    >
    > How would I do this?
    >
    >
    >
    >

    S.M. Altaf [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139