Professional Web Applications Themes

Databind an embedded control in an embedded datagrid - ASP.NET Data Grid Control

All, I have something like the following: Datagrid1 Col1 - bound column Col2 - template column Datagrid1_OnItemDataBound datagrid2 - create new datagrid col1 - template column create new label .text - need to bind data .tooltip - need to bind data I can display the data from the existing dataset using a dataview and rowfilter and setting the DataField property (if I use a boundcolumn instead of the templatecolumn) What I am missing is the expression to bind the data to specific properties of the label control. Typically I would use Databinder.Eval(Container, "DataItem.FIELDNAME"), but I have no Container (I understand ...

  1. #1

    Default Databind an embedded control in an embedded datagrid

    All,

    I have something like the following:

    Datagrid1
    Col1 - bound column
    Col2 - template column

    Datagrid1_OnItemDataBound
    datagrid2 - create new datagrid
    col1 - template column
    create new label
    .text - need to bind data
    .tooltip - need to bind data

    I can display the data from the existing dataset using a dataview and
    rowfilter and setting the DataField property (if I use a boundcolumn instead
    of the templatecolumn)

    What I am missing is the expression to bind the data to specific properties
    of the label control. Typically I would use Databinder.Eval(Container,
    "DataItem.FIELDNAME"), but I have no Container (I understand this must be
    the DatagridItem (Row) object) as it doesn't exist yet. What are my
    options? I will forward my Datagrid1_OnItemDataBound sub to anyone via
    email should you want to see it.

    Thanks,

    Thomas


    Thomas Dodds Guest

  2. #2

    Default Re: Databind an embedded control in an embedded datagrid

    Thomas,
    You could try to set the data source of the bound grid to a custom
    function, mabye pass in some values that will help narrow the selection.
    Then you can use the DataBinder.Eval function in your child grid. You may
    have to save your original data in viewstate to keep it from re-binding over
    and over. I think the visual basic resource kit has some examples.
    Hope this helps,
    Jared

    ex.
    'Child DataGrid's databinding
    DataSource='<%# MyCustomFunction(DataBinder.Eval(Container.DataIte m,
    "SomeIndexedValue")) %>'

    'Codebehind
    Protected Function MyCustomFunction(ByVal SomeIndexedValue As String) As
    DataSet
    Dim conn As New SqlClient.SqlConnection
    conn.ConnectionString =
    "Server=MyServer;Database=MyDataBase;Trusted_Conne ction=True;"
    conn.Open()
    Dim da As New SqlClient.SqlDataAdapter("SELECT * FROM MyTable WHERE
    (MyIndexedField='" & SomeIndexedValue & "')", conn)
    Dim ds As New DataSet
    da.Fill(ds)
    conn.Close()
    Return ds
    End Function

    "Thomas Dodds" <thomasdoddshotmail.com> wrote in message
    news:uDWuc20cEHA.1152TK2MSFTNGP09.phx.gbl...
    > All,
    >
    > I have something like the following:
    >
    > Datagrid1
    > Col1 - bound column
    > Col2 - template column
    >
    > Datagrid1_OnItemDataBound
    > datagrid2 - create new datagrid
    > col1 - template column
    > create new label
    > .text - need to bind data
    > .tooltip - need to bind data
    >
    > I can display the data from the existing dataset using a dataview and
    > rowfilter and setting the DataField property (if I use a boundcolumn
    > instead
    > of the templatecolumn)
    >
    > What I am missing is the expression to bind the data to specific
    > properties
    > of the label control. Typically I would use Databinder.Eval(Container,
    > "DataItem.FIELDNAME"), but I have no Container (I understand this must be
    > the DatagridItem (Row) object) as it doesn't exist yet. What are my
    > options? I will forward my Datagrid1_OnItemDataBound sub to anyone via
    > email should you want to see it.
    >
    > Thanks,
    >
    > Thomas
    >
    >

    Jared Guest

Similar Threads

  1. Custom Server Control Embedded in a DataGrid Event problem
    By Dave in forum ASP.NET Building Controls
    Replies: 0
    Last Post: July 13th, 06:46 AM
  2. DataGrid embedded in a control: no DeleteCommand event firing
    By COUTIER Eric in forum ASP.NET Building Controls
    Replies: 0
    Last Post: December 14th, 09:33 PM
  3. embedded movie control
    By tperez webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 3
    Last Post: December 13th, 09:49 AM
  4. WinForms control embedded in IE
    By Andy Bichel in forum ASP.NET Building Controls
    Replies: 0
    Last Post: October 24th, 09:24 PM
  5. Page Load fired 3 times Web user control is embedded in a custom control
    By Thomas Ekegren in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 3rd, 05:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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