I am trying to populate a text box from a sqldarasource but I keep getting "Object reference not set to instance of an object". Anyone have a clue what im doing wrong? My select statement that I've configured works fine. Here is the code I'm using.
FNTextbox.Text = sqlmedia.SelectParameters["CFN"].ToString();
sqlmedia is a sqldatasource that grabs data from a stored procedure simple statement. i created this using the visual studio toolbox. I do init开发者_StackOverflow中文版ialize earlier in my pageload.
Sounds like you havent instantiated sqlmedia. In your code somewhere you have to create an instance of this class e.g.
sqlmedia = new SqlDataSource();
I think you need to set the "CFN" parameter first:
sqlmedia.SelectParameters.Item("CFN").DefaultValue = value;
精彩评论