Choosing a datagrid column

Discussion in 'ASP .Net' started by Sathyaish, Sep 8, 2005.

  1. Sathyaish

    Sathyaish Guest

    I want to display a column in a datagrid such that each item/row in
    that column acts as a hyperlink. Further, when I click on the
    hyperlink, it doesn't redirect to another page or even to itself.
    Rather it "POSTS" pack to itself, and fetches the values in the entire
    row into the textboxes displayed on the same page outside of the data
    grid.

    >From my understanding of this, I believe I have two courses I could

    follow.

    1. To take a ButtomColumn for the column under question. When the
    button column is clicked, I get the row as DataGridEventArgs.Item in
    the OnItemCommand handler I define.

    This would've worked all well for me had I not made the DataSource of
    the grid my own defined class that derives from DictionaryBase. The
    class, let's call it Group, is a strongly types collection of a class
    GroupMember. GroupMember, let's assume, has three properties, ID,
    MemberName and Email. The column I need to make a hyperlink is the
    MemberName column.

    Since the datasource of the grid is a collection and not a dataset, I
    cannot use the DataTextField property like so:

    <asp:ButtonColumn
    HeaderText = "Member Name"
    DataTextField = "MemberName" />

    because the collection does not have a property called MemberName.
    Instead, it has a key property and a Value property. The value property
    is the GroupMember Object that has a MemberName property. However, I
    cannot even do this:


    <asp:ButtonColumn
    HeaderText = "Member Name"
    DataTextField = "Value.MemberName" />

    The grid won't bind the DataBind() call.

    Neither can I use the DataBinder single-value binding on the
    ButtonColumn event like so:


    <asp:ButtonColumn
    HeaderText = "Member Name"
    DataTextField = '<%# DataBinder.Eval(Container.DataItem,
    "Value.MemberName")%>' />


    because the ButtonColumn class does not support the DataBinding event.



    2. Use the TemplateColumn. If I use the TemplateColumn like so,

    <asp:TemplateColumn HeaderText="Member Name">
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "Value.MemberName")
    %> </ItemTemplate>
    </asp:TemplateColumn>

    It works fine but I do not have hyperlinks, so the main purpose is not
    solved.

    Can you please suggest me a solution to my problem? How do I get a
    hyperlinked column into the grid that reads values from the datasource
    of the grid, which is of type System.Collections.DictionaryBase, and
    such that clicking on the links post back to the same page?
    Sathyaish, Sep 8, 2005
    #1
    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. Jim Hammond
    Replies:
    1
    Views:
    3,610
    bruce barker
    Nov 26, 2003
  2. Hai Nguyen
    Replies:
    0
    Views:
    397
    Hai Nguyen
    Jan 16, 2004
  3. Dexter
    Replies:
    1
    Views:
    416
    Eliyahu Goldin
    Jan 18, 2005
  4. John E.
    Replies:
    3
    Views:
    4,458
    masoud bayan
    Mar 25, 2005
  5. Sathyaish

    Choosing a datagrid column

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    100
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page