DataSet ds;
da = new OleDbDataAdapter("select * from items where newi=" + new1 + " order by slno", con);
ds = new DataSet();
da.Fill(ds, "items");
gridview.DataSource = ds;
gridview.DataBind();
Actually this is the code am using...
When the newi status=true then it shoule display that items details.I had given AcessDataSource ID=datasource and Gridview ID=datasource.
But am getting server error at runtime,the error is
System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'gridview'. Remove one definition.
Hai... I have to take the status field in a gridview,and the datatype of the status is a Yes/No.. the status should change accordingly so that when i click active,it should become inactive and vice-versa.. "iif(status,'Active','InActive') as status from review
" (Here review is the table name and status is the field) This is what am using to display the status of an item according to database. One more thing is,it should automatically change the status in database also.. Am using status in gridview as hyperlink..
and my error is same as yours i.e Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.Could you help me in deleting this error
kdeepu
0 Points
3 Posts
System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'gridview'. R...
Apr 13, 2007 05:42 AM|LINK
DataSet ds;da = new OleDbDataAdapter("select * from items where newi=" + new1 + " order by slno", con);
ds = new DataSet();
da.Fill(ds, "items");
gridview.DataSource = ds;
gridview.DataBind();
Actually this is the code am using...
When the newi status=true then it shoule display that items details.I had given AcessDataSource ID=datasource and Gridview ID=datasource.
But am getting server error at runtime,the error is
System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'gridview'. Remove one definition.
e_screw
All-Star
19530 Points
3894 Posts
Re: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'gridview'....
Apr 13, 2007 08:14 AM|LINK
You have specified the datasource both in the design time and the code-behind(run-time). You need to remove either of these two.
Thanks
Electronic Screw
Website||Blog||Dub@i.net
kdeepu
0 Points
3 Posts
Hai...
Apr 17, 2007 04:52 AM|LINK
Thank U..
At Last I Got The Solution For It .I tried it by writing the following code,
GridView1.DataSource = ds;
GridView1.DataSourceID = String.Empty;
luckilly it worked in my project...
Once again Thanks a lot ...
e_screw
All-Star
19530 Points
3894 Posts
Re: Hai...
Apr 17, 2007 11:41 AM|LINK
Rather, u should remove it in the properties window.
Thanks
Electronic Screw
Website||Blog||Dub@i.net
kdeepu
0 Points
3 Posts
Re: Hai...
Apr 23, 2007 11:23 AM|LINK
manas93411
Member
4 Points
2 Posts
Re: Hai...
Apr 03, 2008 06:36 AM|LINK
Hi thanks for the 2 lines code.....
I have waisted 5 hrs for the same..
rajendrasedh...
Member
6 Points
3 Posts
Re: Hai...
May 08, 2008 04:25 PM|LINK
Thank you very much....I also spend more than 2 hours ....... [:@]
Gayathri_Sri...
Member
15 Points
32 Posts
Re: Hai...
May 30, 2008 06:13 AM|LINK
Thank you screw. Thats the mistake i did. Thank again
karanpaul
Member
76 Points
33 Posts
Re: Hai...
Jun 02, 2008 10:44 AM|LINK
hi deepu,
GridView1.DataSource = ds;
GridView1.DataSourceID = String.Empty;
U said it worked for u .But cannot find that as solution.Are u using antthing like this
GridView1.DataSource = ds;
GridView1.DataBind();
during databind i m getting the sam error ."Both....REmove on definition".Moreover i have not defined anything at design time.Can u please help me
Paul
lakshmi_komm...
Member
2 Points
1 Post
Re: Hai...
Nov 07, 2008 11:57 AM|LINK
byte[] myimage = new byte[imageupload.PostedFile.ContentLength]; HttpPostedFile Image = imageupload.PostedFile; Image.InputStream.Read(myimage, 0, (int)imageupload.PostedFile.ContentLength); SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["dateofbirthConnectionString3"].ConnectionString); SqlCommand storeimage = new SqlCommand("INSERT INTO dobtable " + "(Image_Content, Image_Type, Image_Size,day,month,year,imagename) " + " values (@image, @imagetype, @imagesize,@day,@month,@year,@imagename)", myConnection); storeimage.Parameters.Add("@day", ddlday.SelectedItem.Text); storeimage.Parameters.Add("@month", ddlmonth.SelectedItem.Text); storeimage.Parameters.Add("@year", ddlyear.SelectedItem.Text); storeimage.Parameters.Add("@image", SqlDbType.Image).Value = myimage; storeimage.Parameters.Add("@imagename", txtimagename.Text); storeimage.Parameters.Add("@imagetype", SqlDbType.VarChar, 100).Value = imageupload.PostedFile.ContentType; storeimage.Parameters.Add("@imagesize", SqlDbType.BigInt, 99999).Value = imageupload.PostedFile.ContentLength; myConnection.Open(); storeimage.ExecuteNonQuery(); myConnection.Close(); GridView1.DataSource = FetchAllImagesInfo(); GridView1.DataBind();
and my error is same as yours i.e Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.Could you help me in deleting this error