I would like to add an Edit column hyperlink dynammically so the user can select it to link to another page and edit the record select. I have been looking at 2 methods for this but have to come up with any results. The reson this is dynamic is becuase the data being read in has a dynamic number of columns. But one column will always be a RecId, which is what I want to pass to the Edit page.
Here are the 2 methods I've been looking into:
1. Read data into a DataTable object. Then add another column. I can add another column easily enough. I set the type as a Hyperlink and then looped through the DataTable, grabing the value of RecId, and appending that to a HyperLink object navigate url like this:
hl.NavigateUrl = "~/web/RecordEdit.aspx?rec
=" + hlRec; // where hlRec is a string of the RecID
After this, I set the the DataTable as the source of a GridView and DataBind for display. The problem here is that GridView shows all the records except the additional column. (No suntax or run-time errors were encountered.)
2. Read data into a DataTable object, the set it as the DataSource for the GridView. Before DataBind on the GridView, create a HyperLinkField, set the header text and text, and add it to the GridView. Then DataBind the GridView. This does add the additional column and it displays, but I'm having troubles setting the NavigateUrl on the HyperLinkField items so that they link to the Edit page, apending the RecId from another column.
I could please use some assistance with either of these methods or if you have another way to accomplish the functionality I'm looking for, that's cool as well. There isn't a lot of records being returned now (in development) but there probably will be when this gets up and running (probably not over 10,000 or anything but still a 200 or 300 or 1000 is still enough to effect lag here).
I have been all over the web the last few days and am finding similiar things but nothing quite like what I'm trying to do. I've also read this result (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23249566.html
) but I can quite figure out how to tailor it to what I'm doing.
I'm using ASP.Net 3.5 C#. Thanks for your help.