'System.Data.Common.DbDataRecord' does not contain a property with the name PRODUCT_NAME.

A

Aaron Radich

I'm trying to use a populate a asp:Repeater with a DataReader control.
When I try to reference the bound data column like this:

<asp:Repeater id="rptProductButtonList" runat="server">
<ItemTemplate>
<tr valign="middle">
<td align="center">
<%# DataBinder.Eval(Container.DataItem, "PRODUCT_NAME") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>

I get this error: DataBinder.Eval: 'System.Data.Common.DbDataRecord'
does not contain a property with the name PRODUCT_NAME. Does anyone
know what my problem is? My code behind code that populates the data
reader is as follows:

private void LoadAvailableGames(int PartnerId, int SiteId)
{
// open a db connection
String sConnectionString =
ConfigurationSettings.AppSettings["DBConnectString"];
SqlConnection objConn = new SqlConnection(sConnectionString);

SqlCommand objSqlCommand = new
SqlCommand("sps_partner_site_license_count", objConn);
objSqlCommand.CommandType = CommandType.StoredProcedure;

// add the parameters
SqlParameter prmPartnerId =
objSqlCommand.Parameters.Add("@PARTNER_ID", SqlDbType.Int);
prmPartnerId.Value = PartnerId;
SqlParameter prmSiteId =
objSqlCommand.Parameters.Add("@PARTNER_SITE_ID", SqlDbType.Int);
prmSiteId.Value = SiteId;

// open the connection
objConn.Open();

// execute the stored procedure and fill the data reader
SqlDataReader objDataReader = objSqlCommand.ExecuteReader();

// populate the product list repeater
rptProductButtonList.DataSource = objDataReader;
rptProductButtonList.DataBind();

//objDataReader.Close();
//objConn.Close();

}


Aaron
 
M

Mark Fitzpatrick

Have you verified that the data being returned does contain the PRODUCT_NAME
field? This one catches a lot of peopl as sometimes the SQL query or stored
procedure just isn't selecting all the fields they think.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top