Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Thomas Dodds #1
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
-
Custom Server Control Embedded in a DataGrid Event problem
Hi All, I have successfully created a Custom Server Control which is a Table that has an ImageButton in one of it's cells. When I use this... -
Embedded windows control in ASP.NET
Hi all, We are trying to create a windows control and embed it in an ASP ..NET page. The problem is, this control is based on another 3rd party... -
DataGrid embedded in a control: no DeleteCommand event firing
Hello, I've writted a composite control that contain a datagrid and some other controls (button, checkbox, etc...) In the CreateChildControls,... -
WinForms control embedded in IE
Hello everyone, I have a .NET Windows User Control hosted in an .aspx page using the Object tag. This User Control needs to reference a thrid... -
Page Load fired 3 times Web user control is embedded in a custom control
Hi, I have built a custom control that build a table with 3 cells in it. The custom control is designed to add all child controls to cell#2,... -
Jared #2
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" <thomasdodds@hotmail.com> wrote in message
news:uDWuc20cEHA.1152@TK2MSFTNGP09.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



Reply With Quote

