Click here to Skip to main content
15,922,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In ListView I took one Button
XML
<asp:Button ID="btnsubmit" runat="server" Text="SUBMIT" OnClick="btnsubmit_Click" CommandArgument='<%# Eval("id")%>'/>

so when write CommandArgument='<%# Eval("id")%>'/>;
here id is primary key of table Smart_Pin

I get this error
C#
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'id'.


What is the solution ?
Posted
v2
Comments
Can you post the code where you bind the ListView and SQL Query used to fetch the data ?
choudhary.sumit 4-Dec-12 2:30am    
did you forget to bind your listview to the appropriate dataset??

1 solution

You are binding the Button to the ListView itself, not the ListViews dataset.

Try this:
C#
<![CDATA[<%# DataBinder.Eval (Container.DataItem, "id") %>


CodeProject is adding the <![CDATA[ don't copy that part.

You might also need to do a Parent.DataItem...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900