Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Sathyaish #1
Choosing a datagrid column
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.
follow.>From my understanding of this, I believe I have two courses I could
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 Guest
-
Move bound column to right of dynamic column in datagrid?
I have a datatable that I am binding to a C# ASP.NET 1.1 web page. I also want to put an "Edit" column on the datagrid. However, whenever I use... -
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column
i am trying to trap the value of one dropdownlist (in a datagrid edititemtemplate column) at the time its selectedindexchanged event fires and use... -
Bound Column or Template Column (w dAdapater?) in DataGrid
I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL... -
Convert an MS Access Yes/No column to a checkbox column in C# datagrid
Currently I have a datagrid displaying the multiple columns of data (text and numerical) found in a table in MS Access. In the Access table,... -
Choosing a column on the fly
You can use Dynamic SQL ... To achieve the same ... -- HTH, Vinod Kumar MCSE, DBA, MCAD SCT Software Solutions ...



Reply With Quote

