Class 'System.Web.UI.WebControls.DataGridItem' cannot be indexed

M

MS

I am very new to asp.net. Please help me in resolving the error:
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property
with the name RENEW_EXIST.
I get the above error with the following code in aspx page
<asp:Label ID="lblRenewExist" Visible="False" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "RENEW_EXIST") %>' />

If I change DataBinder.Eval(Container.DataItem, "RENEW_EXIST") to
Container(DataItem."RENEW_EXIST"), the error message is changed to
BC30367: Class 'System.Web.UI.WebControls.DataGridItem' cannot be
indexed because it has no default property.
PLEASE HELP!!!

Dim oDA = New System.Data.SqlClient.SqlDataAdapter()
Dim oConn = New System.Data.SqlClient.SqlConnection()
Dim oCmd = New System.Data.SqlClient.SqlCommand()
Dim oDs = New DataSet()
oConn = Application("ConnString")
oDA.SelectCommand = oCmd
oDA.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "SPAR_REL", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("REL_ID", "REL_ID"), New
System.Data.Common.DataColumnMapping("REL_NAME", "REL_NAME"), New
System.Data.Common.DataColumnMapping........("RENEW_RATE",
"RENEW_RATE"), New System.Data.Common.DataColumnMapping("RENEW_NOTICE",
"RENEW_NOTICE"), New
System.Data.Common.DataColumnMapping("RENEW_EXIST", "RENEW_EXIST")})})

'SqlSelectCommand1 '
oCmd.CommandText = "[sp_SPAR_SelectCmdRel]"
oCmd.CommandType = System.Data.CommandType.StoredProcedure
oCmd.Connection = oConn
oCmd.Parameters("@CSM_ID").Value = Session("User_ID")
oDA.Fill(oDs, "SPAR_REL")
DataGrid1.DataSource = oDs
DataGrid1.DataBind()
 
K

kafmil

I have the same problem at the moment.

System.Web: DataBinder.Eval: 'System.Web.UI.WebControls.DataGridItem'
does not contain a property with the name sTitle...

I removed the offending item in the datagrid but it didn't help as
the next item threw the same error. I have looked through my datatable
in the command window in VS and found that all the necessary fields
are present so i don't understand why it is not working.

I am using template columns in my datagrid as follows:
<ItemTemplate><asp:Label ID="Label1" Runat="server"
Text='<%# DataBinder.Eval(Container, "sTitle")
%>'></asp:Label></ItemTemplate>
<EditItemTemplate><asp:TextBox ID="Textbox1" Runat="server"
CssClass="clsInput" Text='<%# DataBinder.Eval(Container, "sTitle")
%>'></asp:TextBox></EditItemTemplate>

and the field sTitle is definately in the datatable

any help would be much appreciated
 
K

kafmil

I've figured it out.
I am now using

DataBinder.Eval(Container.DataItem, "dtDateExpires", "{0:dd MMM yyyy}")

in the datagrid and it works fine.

Kurt
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top