Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am using the database connectivity Using an Entity data model.

Error: Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.

What can in replace with gvNewsGroup.datasource?
C#
NewsGroup newsgroup = new NewsGroup() { 

PageTitle=txtPageGroup.Text
};
content.NewsGroup.Add(newsgroup);
content.SaveChanges();
gvNewsGroup.DataSource = newsgroup;
gvNewsGroup.DataBind();
Posted
Updated 14-May-13 5:49am
v2
Comments
Yuriy Loginov 14-May-13 11:36am    
what exactly are you trying to achieve? if you only need to save the data then just use this:
NewsGroup newsgroup = new NewsGroup() {
PageTitle=txtPageGroup.Text
};
content.NewsGroup.Add(newsgroup);
content.SaveChanges();
behnamhaji 14-May-13 11:38am    
i want bind it to grid of page
Yuriy Loginov 14-May-13 11:42am    
then try this:
gvNewsGroup.DataSource = context.NewsGroup.ToList();
gvNewsGroup.DataBind();

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