custom templateColumn

Discussion in 'ASP .Net Web Controls' started by Assaf, Sep 29, 2003.

  1. Assaf

    Assaf Guest

    I am writing a custom itemplate to be used by a
    templateColumn in a datagrid. How do I get my hands on the
    datagrid's data so I can insert custom contents with
    respect to it. In other words, I want to define a
    template column class that does something like this:

    <asp:datagrid id="dg" runat="server"
    AutoGenerateColumns="False">
    <Columns>

    <asp:TemplateColumn>
    <ItemTemplate>
    '**************************************************
    "abc" + <%# DataBinder.Eval
    (Container.DataItem, "Description") %></td>
    '**************************************************
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>


    And I want to know where I can get my hands on the
    equivalant of <%databinder.eval(...)%> in my code. My
    code is as follows:

    Public Class inputBoxTemplateColumn
    Implements ITemplate
    Dim _templateType As ListItemType
    Dim _columnName As String
    Dim _data As DataTable

    Sub New(ByVal type As ListItemType, ByVal ColName
    As String)
    _templateType = type
    _columnName = ColName
    End Sub


    Sub InstantiateIn(ByVal container As Control) _
    Implements ITemplate.InstantiateIn
    Dim str As string
    Dim box As New TextBox
    Select Case _templateType
    ...
    Case ListItemType.Item
    '***str = ???(value from dataset)
    container.Controls.Add(str)
    ...

    End Select
    End Sub
    End Class

    Any help, direction, or suggestions would be greatly
    appreciated.
     
    Assaf, Sep 29, 2003
    #1
    1. Advertising

  2. http://msdn.microsoft.com/msdnmag/issues/03/06/CuttingEdge
    /default.aspx

    the article has a good example. You need to create a
    function to Resolve DataSource, then use IEnuerable to
    get DateBinder.Eval.

    Yukking Cheung

    >-----Original Message-----
    >I am writing a custom itemplate to be used by a
    >templateColumn in a datagrid. How do I get my hands on

    the
    >datagrid's data so I can insert custom contents with
    >respect to it. In other words, I want to define a
    >template column class that does something like this:
    >
    ><asp:datagrid id="dg" runat="server"
    > AutoGenerateColumns="False">
    > <Columns>
    >
    > <asp:TemplateColumn>
    > <ItemTemplate>
    >'**************************************************


    > "abc" + <%# DataBinder.Eval
    >(Container.DataItem, "Description") %></td>
    >'**************************************************
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    ></asp:datagrid>
    >
    >
    >And I want to know where I can get my hands on the
    >equivalant of <%databinder.eval(...)%> in my code. My
    >code is as follows:
    >
    > Public Class inputBoxTemplateColumn
    > Implements ITemplate
    > Dim _templateType As ListItemType
    > Dim _columnName As String
    > Dim _data As DataTable
    >
    > Sub New(ByVal type As ListItemType, ByVal

    ColName
    >As String)
    > _templateType = type
    > _columnName = ColName
    > End Sub
    >
    >
    > Sub InstantiateIn(ByVal container As Control) _
    > Implements ITemplate.InstantiateIn
    > Dim str As string
    > Dim box As New TextBox
    > Select Case _templateType
    > ...
    > Case ListItemType.Item
    > '***str = ???(value from dataset)
    > container.Controls.Add(str)
    > ...
    >
    > End Select
    > End Sub
    > End Class
    >
    >Any help, direction, or suggestions would be greatly
    >appreciated.
    >
    >.
    >
     
    Yukking Cheung, Sep 30, 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. Bob
    Replies:
    0
    Views:
    633
  2. Nus Pieds

    TemplateColumn CheckBox

    Nus Pieds, Jul 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    395
    Nus Pieds
    Jul 16, 2003
  3. Edward

    TemplateColumn Width

    Edward, Nov 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,249
    S. Justin Gengo
    Nov 21, 2003
  4. tshad
    Replies:
    0
    Views:
    333
    tshad
    Jan 25, 2005
  5. Chu
    Replies:
    0
    Views:
    522
Loading...

Share This Page