Choosing a datagrid column

S

Sathyaish

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top