473,322 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Getting a DataGrid to flexibly display a DataView

This is a repost from the other dotnet.csharp forum:

I'm including a simple datagrid control on my web form. I have created
a Dataview (reportListView) onto a data table to populate it. At its
simplest it works - if I define the datasource for the grid to be
'reportListView' and use autogenerate columns then I get all columns
of the view appearing when the page is viewed.
However I now want to restrict the number of columns to be displayed
and also to create a hyperlink column. This should be simple, but when
I try to define the columns (within the properties of the grid), I
don't get any opportunity to select individual fields in the data
source (whereas all of the documentation implies that I will be able
to do so). For instance, no columns are available in the 'Available
Columns' window; I can't see any text fields within the
HyperlinkColumn properties, etc.
It's as if the dataview cannot be expanded correctly when I'm
designing the grid. I'm extremely inexperienced in this area, so any
advice gratefully appreciated.
- Rob.
Nov 15 '05 #1
1 3113
You could use, asp:TemplateColumn to have this hyperlink
field. Here is the sample code.

Thanks,
Muhammad Arif
System Analyst, UHC

<asp:datagrid id="ReportGrid" AutoGenerateColumns="False"

Runat="server">

<ItemStyle
HorizontalAlign="Center"></ItemStyle>

<HeaderStyle Font-Size="10pt" Font-
Names="Verdana" Font-Bold="True" HorizontalAlign="Center"
BackColor="#D4DEE3"></HeaderStyle>

<Columns>
<asp:TemplateColumn HeaderText="Download Voice File">

<HeaderTemplate>

Voice
Dictation

</HeaderTemplate>

<ItemTemplate>
<asp:hyperlink runat="server"
Text="Listen/Download" NavigateUrl='<%
# "../../CommonServices/WebPages/DownloadWavFile.aspx?id="
+DataBinder.Eval(Container.DataItem,"VoiceFileName ") %>'
Target="_new" ID="Hyperlink3"/>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn
HeaderText="Report Activity Log">

<HeaderTemplate>

Report
Activity Log

</HeaderTemplate>

<ItemTemplate>
<ASP:HYPERLINK id=hlViewActivityLog runat="server"
Target="_new" NavigateUrl='<%# "HViewActivityLog.aspx?id="
+DataBinder.Eval(Container.DataItem,"PkId") %>' Text="View
Log" />

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

</asp:datagrid>
-----Original Message-----
This is a repost from the other dotnet.csharp forum:

I'm including a simple datagrid control on my web form. I have createda Dataview (reportListView) onto a data table to populate it. At itssimplest it works - if I define the datasource for the grid to be'reportListView' and use autogenerate columns then I get all columnsof the view appearing when the page is viewed.
However I now want to restrict the number of columns to be displayedand also to create a hyperlink column. This should be simple, but whenI try to define the columns (within the properties of the grid), Idon't get any opportunity to select individual fields in the datasource (whereas all of the documentation implies that I will be ableto do so). For instance, no columns are available in the 'AvailableColumns' window; I can't see any text fields within the
HyperlinkColumn properties, etc.
It's as if the dataview cannot be expanded correctly when I'mdesigning the grid. I'm extremely inexperienced in this area, so anyadvice gratefully appreciated.
- Rob.
.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tonya | last post by:
Hi, I need help on datagrid control. I am currently using it to display all the data from a particular table from my DB. What i want is the ability for the user to select a row (the whole row...
0
by: Frnak McKenney | last post by:
I have a (small) multi-table database application which allows edits, print reports, and has two scrolling screen displays which show information merged from multiple tables. I'm having trouble...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
5
by: Jason | last post by:
I've been trying to figure out a good way to do this but haven't had much luck, any input would be greatly appreciated. Basically, after a datagrid is sorted, how can I get the primary key value...
3
by: Tim McKinney | last post by:
I have a read-only datagrid that I use to display a heirarchal model of three tables (The example I am setting up uses the Customer, Orders, and Order Detail tables from the northwind database). I...
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
3
by: astro | last post by:
I have a datagrid that is two levels down from the dataview (i.e. grandchild). I have spent 3 hours trying to get the syntax of determining it's real datasource (i.e. not it's source based on it's...
9
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.