Extracting the value of an <A HREF...> in a TemplateColumn

I have this column in my datagrid:

<asp:TemplateColumn SortExpression="OrderLineNo" HeaderText="Line No">

<a href="#" onclick='ViewPOLine(<%# DataBinder.Eval(Container.DataItem, "OrderNo") %>,<%# DataBinder.Eval(Container.DataItem, "OrderLineNo") %>)'><%# DataBinder.Eval(Container.DataItem, "OrderLineNo") %></a>
I also have another template column with a Textbox control and when that changes, in the TextChanged event handler, I want to get the value of the anchor control above so I know which order line to update.
If I try this:
HtmlAnchor link = (HtmlAnchor)dgi.Cells[1].Controls[0];

string strPOLine = link.InnerText;
it falls over with "Specified cast is not valid".
I've also tried casting it to a generic HTML control then getting the InnerHtml property but it returns the entire HTML string generated by ASP.Net for the control - I just want the actual value of OrderLineNo in the anchor (ie: an integer)... can anyone tell me how to do this?
6/18/2004 6:36:14 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 35

Just add runat="server" attribute to the declaraion of the hyperlink otherwise your control is just a literal control to the framework
Bug [MCSD]
6/18/2004 9:36:14 AM
Well spotted! I can't beleive I overlooked that... sometimes it's the simplest thing and you get bogged down looking for a more complicated answer.

6/18/2004 9:52:22 PM

Similar Artilces:

Unwanted text gets generated ( &lt;div&gt;&lt;div&gt;&lt;endnote&gt; )
Hi! My RadialContext extension provides a radial menu via DHTML. With newer versions of Mozilla, unwanted extra text gets sometimes inserted before the labels: &lt;div&gt;&lt;div&gt;&lt;endnote&gt; I basically have no clue what could cause this. Here's the code generating the labels: // add and adjust labels var icnt= this.items.length; for(var i=0; i< icnt; i++) { var xpos= (i>=icnt/2)? 8: 188; var ypos= ((i< icnt/2)? ((i+1)*8/icnt)*22: -((i+1)*8/icnt)*22+ 8*22)- i*22- 108; var tdiv= pie_context.frame_doc.createEle...

how do i do &lt;a href="#name"&gt; &lt;a name="name"&gt; on immagebutton
if the page is too long, when the page is posted back, i want it to move to original location where the user click it. can i do it with imagebutton without using Response.Redirect ?...

&& In Generated Javascript Becomes &amp;&amp;
I am trying to write client side scripts in c#, asp.net V 1.4. The && operator is generated in the javascript as &amp;amp;, which causes errors.  How can I avoid this? (Code below)  Thanks in advance.   script = "<script language='javascript' type='text/javascript'>\n"; script += "if (Form1." + tbxA.ClientID + ".value == '' && "; script += "Form1." + tbxB.ClientID + ".value == '') {"; script += "Form1." + cbxC.ClientID + ".Checked = false;}"; ...

I have the following html, which if placed in an html page renders exactly what I want - a header, a left "menu bar" and a scrolling main body area. However, when I place the same code in an aspx page, it basically ignores(?) the height settings, and "scrunches" everything up at the top. <div style="WIDTH:100%; HEIGHT:15%; BACKGROUND-COLOR:blue" align="center"> <br> This is the header</div> <div style="height: 85%"> <div s...

&lt;noscript&gt; tag inside &lt;p&gt; using XHTML 1.0 Strtict
I am using a simple Javascript technique to hide email addresses from spiders. Its basic format is this: <p>You may send an email to <script type="text/javascript">snugglepot('retsila','moc.3noitide');</script></p>This works fine, and validates as XHTML 1.0 Strict. I then realised that I'd made to provision for browsers without Javascript. So, I did what I thought was obvious: <p>You may send an email to <script type="text/javascript">snugglepot('retsila','moc.3noitide');</script><noscript>&laquo;hidden&r...

DetailsView Converts '<' & '>' to '&lt;' & '&gt;'
I have multi-line textboxes from which the data is stored as a text value in the SQL database. Before the data is passed to the stored procedure, the text is parsed to replace all vbNewLIne and vbLf cases with "<br/>". This is done successfully, storing the text in the database with the "<br/>" tags. When the data is displayed, I want the text data dropped into the page as is; meaning "<br/>" in the database appears as "<br/>" in the source. However, the DetailsView object into which the values are being passed seems to be trans...

& where shown as &amp;
hai,     At runtime i will add values from textbox to datagrid using datatables.what my problem was , when i add as he & she in textbox it show as he &amps; she in the grid.how to solve this. Thanks in advance   cool.mugil:    At runtime i will add values from textbox to datagrid using datatables.what my problem was , when i add as he & she in textbox it show as he &amps; she in the grid.how to solve this.  Make sure you are not HTML encoding the input values.  Hai,    How to do stop html enc...

& turning to &amp;
I'm doing an operation reformat and trying to use the & in a text box. In the trace it looks ok in the policy, but when it gets to the actual xml value it turns into this: <modify-attr attr-name="EG"> <remove-all-values/> <add-value> <value>&amp;</value> </add-value> </modify-attr> Can I fix this in policy builder or by escaping the character somehow? Or do I need a stylesheet to fix the problem? -- nate_spears ------------------------------------------------------------------------ It isn't a p...

&, &&, and backtracking.
------=_Part_20601_33098141.1189046184291 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline How do C<&> and C<&&> differ with respect to backtracking? For instance, "foobar" ~~ / <[a..z]>+ & [ ... ] /; Both sides of the C<&> happen in parallel, so I would guess that they both match "foo" then stop. Please correct me if that's wrong. Were we using the procedural conjunction: "foobar" ~~ / <[a..z]>+ && [ ... ] /; I would gues...

&amp; instead of &
I have gridview with the following code on row commandDim row As GridViewRow = gvBusinessLines.Rows(e.CommandArgument)txtBusinessLine.Text = CStr(row.Cells(1).Text) ''''''''''''''''''''''''''''''''''''''''''''''' When I have this text in gridview for example:"test & test2", when clicking on the button of the gridview, textbox is containing test &amp; test2How to avoide this other than re...

Convert &amp; to &
I have a Gridview that is populated by the 3 different users from selections made in a prior Form.  This gridview summarizes everything.  I then step through this Gridview and write the data to a history file on SQL. The problem I am having is, one column in this Gridview is a name column which contains the "&" symbol.  When I iterate the Gridview and populate the history file the & becomes &amp;.  I can't seem to figure out how to convert this properly.  Both data fields are nvarchar type.  Please help anyone. This is the code to tak...

If & =&amp; in xml then { or }= what?
Hi frnds, some problem when using xml & is not compatible in xml file so we replace & with &amp;    like that i want to know what the characters which are not compatible with xml syntax for example when i m using { or } in xml file then its shwoing error msg. if anyone knows the soln then plz reply me. Thanks in advance.Regards,Hasan Mohiuddin Farooqihasan_farooqi@yahoo.co.in Hi Dear,Please find the Table. It contains the all special character list... quot " U+0022 (34) HTML 2.0 HTMLspecial ISOnum quotation mark (= APL quote) amp &am...

Replacement of & , &amp;
I was trying this java script inside a mozilla extension but the browser shows me error this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); XML Parsing Error: not well-formed at replace(/&/g,'&amp;') Any thoughts ? Thanks On Fri, 30 May 2008 10:26:19 -0700 (PDT), sb wrote: > I was trying this java script inside a mozilla extension but the > browser shows me error > this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); > ...

Name: LeceHoigree Email: 101atmanga-kenseidotcom Product: eBay Companion Summary: Kfarbair.com - &#1489;&#1497;&#1514; &#1502;&#1500;&#1493;&#1503; &#1499;&#1508;&#1512;&#1497; & &#1495;&#1491;&#1512;&#1497;&#1501; &#1502;&#1512;&#1493;&#1493;&#1495;&#1497;&#1501; & &#1499;&#1508;&#1512; &#1489;&#1506;&#1497;&#1512; Comments: <a href=http://www.kfarbair.com><img>http://www.kfarbair.com/_images/_photos/photo_big8.jpg</img></a> ...

Web resources about - Extracting the value of an &amp;lt;A HREF...&amp;gt; in a TemplateColumn - asp.net.presentation-controls

Elise Andrews
Rowing Online Management System (ROMS) - Australia - Powered by Decimalware

BlueVision, LLC - .NET Tips and Tricks
Note: Some tips might become outdated as new versions of the associated products are released. Debugging the OnStart method of a Windows Service ...

[JavaScript] ////////// controller Ext.define('couchtest.controller.MyController', { - Pastebin.com
////////// controllerExt.define('couchtest.controller.MyController', { extend: 'Ext.app.Controller', config: { control: { ".staff-update-button": ...

Fully Editable Datagrid - Pale Musings
This is the text from an article I wrote back in April of 2003 and had published on the original DotNetJunkies site. After my recent change in ...

Resources last updated: 12/4/2015 6:23:50 PM