| re: Getting a DataGrid to flexibly display a DataView
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>
[color=blue]
>-----Original Message-----
>This is a repost from the other dotnet.csharp forum:
>
>I'm including a simple datagrid control on my web form. I[/color]
have created[color=blue]
>a Dataview (reportListView) onto a data table to populate[/color]
it. At its[color=blue]
>simplest it works - if I define the datasource for the[/color]
grid to be[color=blue]
>'reportListView' and use autogenerate columns then I get[/color]
all columns[color=blue]
>of the view appearing when the page is viewed.
>However I now want to restrict the number of columns to[/color]
be displayed[color=blue]
>and also to create a hyperlink column. This should be[/color]
simple, but when[color=blue]
>I try to define the columns (within the properties of the[/color]
grid), I[color=blue]
>don't get any opportunity to select individual fields in[/color]
the data[color=blue]
>source (whereas all of the documentation implies that I[/color]
will be able[color=blue]
>to do so). For instance, no columns are available in[/color]
the 'Available[color=blue]
>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[/color]
I'm[color=blue]
>designing the grid. I'm extremely inexperienced in this[/color]
area, so any[color=blue]
>advice gratefully appreciated.
>- Rob.
>.
>[/color] |