473,396 Members | 1,938 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,396 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 15 '05 #1
1 1341
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 15 '05 #2

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

Similar topics

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: 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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.