Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Unable to cast object error when looping thru table

$
0
0

What is wrong with either of these?

I receive the following when i debug:

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox

 

TextBox txtQty = (TextBox)row.Cells[1].Controls[0];
                TextBox txtPart = (TextBox)row.Cells[2].Controls[0];
                TextBox txtUnit = (TextBox)row.Cells[3].Controls[0];


                var txtQty = (TextBox)row.Cells[1].Controls[0];
                var txtPart = (TextBox)row.Cells[2].Controls[0];
                var txtUnit = (TextBox)row.Cells[3].Controls[0];


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>