Binding data in a TemplateField
My main problem with this code is that it feels "rambling". Things happen in the right order, but it's all mangled. For instance: 


You retrieve hidField on line 6 and then don't use it until line 13. 
You retrieve pnl on line 14 and then don't do anything with it until line 33.
You create tbldetails on line 7 but assign its property CssClass only on line 12 (and "table" is IMHO a bad css class name).


Etcetera. Group these assignments so the code become more logical, so there's more of a flow.



Variable altField isn't used at all.



I'm not a big fan of mixing LINQ styles, and I find the SQL-like version often too verbose. Example:

(from q in db.GetTable&lt;priceData&gt;()
where q.ID == rowID
select q).FirstOrDefault();


... can be rewritten as:

db.GetTable&lt;priceData&gt;().FirstOrDefault(x =&gt; x.ID == rowID);




priceData is a class name, so why then is it camelCase instead of PascalCase?



Why not use var instead of repeating the class name like here:

TableHeaderRow tblheaderrow = new TableHeaderRow();
TableHeaderCell tblheadercell = new TableHeaderCell();
Table tbldetails = new Table();




Compound words should have a capital at each compounded word, so it should be tblHeaderRow instead of tblheaderrow etc.



Avoid abbreviations. Why hidField and not hiddenField?



This is "old style" C#:

TableHeaderCell tblheadercell = new TableHeaderCell();
tblheadercell.Text = "Details";


These days I'd expect to see this:

var tableHeaderCell = new TableHeaderCell
{
   Text = "Details"
};




Now, WRT your approach: it depends on the volume of data. If this detail table isn't that "heavy" and the main table isn't that big, I would consider filling it up for each row by default and toggling its visibility through client-side code (JavaScript/JQuery + CSS). Not that in this case you should NOT retrieve it ID by ID, but instead in one query.

If that's too much data to send to the browser in one go, then I'd consider your way. There really is no "one size fits all" solution, it all depends on the volume of data and what your users expect from your UI.