473,326 Members | 2,255 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,326 software developers and data experts.

advancing with the asp:datagrid

In my .cs code I populate set the DataSource appropriately and I can
get my DataGrid to appear, though sorting throws an error
'dgDataGrid1__ctl1__ctl0' of type 'DataGridLinkButton' must be placed
inside a form tag

But ignoring that, with my asp:DataGrid how can I have a column of
values each with a link e.g.

<a href="Details.aspx?id=" + MY_NBR>MY_NBR</a>
<asp:DataGrid id="ReportHeader" runat="server" AllowSorting="True"
AutoGenerateColumns="False" >
<Columns>
<asp:BoundColumn DataField="MY_GROUP"
HeaderText="Report Group" SortExpression="MY_GROUP">
</asp:BoundColumn>
<asp:BoundColumn DataField="MY_NAME"
HeaderText="Report Name" SortExpression="MY_NAME">
</asp:BoundColumn>
<asp:BoundColumn DataField="MY_NBR"
HeaderText="Report Nbr" DataFormatString="{0:d}"
SortExpression="MY_NBR">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>

thanks!
Nov 18 '05 #1
1 946
That's what the HyperLinkColumn is for. You set the field that you pull for
the URL (in this case, MY_NBR), then set the format string, and then the {0}
portion will substitute in the field from the database. The DataTextField
property then shows what to display, and if you want to decorate this
somehow just use the DataTextFormatString property.

eg:

<asp:HyperLinkColumn HeaderText="Report Nbr" DataNavigateUrlField="MY_NBR"
DataNavigateUrlFormatString="details.aspx?id={0}" DataTextField="MY_NBR" />
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Tim Smith" <ti*******@hotmail.com> wrote in message
news:a7**************************@posting.google.c om...
In my .cs code I populate set the DataSource appropriately and I can
get my DataGrid to appear, though sorting throws an error
'dgDataGrid1__ctl1__ctl0' of type 'DataGridLinkButton' must be placed
inside a form tag

But ignoring that, with my asp:DataGrid how can I have a column of
values each with a link e.g.

<a href="Details.aspx?id=" + MY_NBR>MY_NBR</a>
<asp:DataGrid id="ReportHeader" runat="server" AllowSorting="True"
AutoGenerateColumns="False" >
<Columns>
<asp:BoundColumn DataField="MY_GROUP"
HeaderText="Report Group" SortExpression="MY_GROUP">
</asp:BoundColumn>
<asp:BoundColumn DataField="MY_NAME"
HeaderText="Report Name" SortExpression="MY_NAME">
</asp:BoundColumn>
<asp:BoundColumn DataField="MY_NBR"
HeaderText="Report Nbr" DataFormatString="{0:d}"
SortExpression="MY_NBR">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>

thanks!

Nov 18 '05 #2

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

Similar topics

1
by: Tim Smith | last post by:
In my .cs code I populate set the DataSource appropriately and I can get my DataGrid to appear, though sorting throws an error 'dgDataGrid1__ctl1__ctl0' of type 'DataGridLinkButton' must be placed...
1
by: Paresh | last post by:
Hi I need to Print asp:datagrid with formatting, which will avoid my writing of crystal reports and can directly print with click of a button. I do not just want to print the current page, I...
1
by: Michael M | last post by:
Hi I am trying to add mouseover property to asp:datagrid in the asp .net page My pag So the output in HTML for a row should look like <tr style="onmouseover=this.bgcolor=#ff0000;...
6
by: RSB | last post by:
Hi Everyone, i am using a ASP: DataGrid control in the page and for each row i have a Delete Button Column. Every thing works fine. But now i want to add a Java script confirmation check for the...
4
by: Mark Travis | last post by:
Hi all, I have written a simple Web Application that displays a query result onto a page using the ASP DataGrid. To Digress ======= Development information about the page is as follows 1....
2
by: John | last post by:
Hi, First off .. I am very new to ASP.NET (.NET in general), so this may be a very basic question. I have traditionally used a set of style classes for html tables and the first row in those...
15
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
2
by: =?Utf-8?B?RXNlbWk=?= | last post by:
I have a datatable that contains a number of web addresses as type nvarchar (eg 'www.msdn.com'). I want to use these as hyperlinks in a datagrid column. Whats the best way to do this? How can I...
2
by: getziiiiiiiiiii | last post by:
Hi There. . I need some help in paging (which is not working) in ASP:DATAGRID My Data source id is a function which returns DataTable to this datagrid. Do i need a code behind to get the next...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: 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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.