Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-04-2012, 06:21 PM   PM User | #1
coxmg
New Coder

 
Join Date: Sep 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
coxmg is an unknown quantity at this point
Need both form level and Code Behind Gridview VB.NET

Hey, guys question for you. I am getting an error, both datasource and datasourceID defined, please remove one of them. what I am trying to do is to set default values for a gridview from the pageload event and also allow the form level usage of datasourceID to set data inside the gridview. I am trying to set the data inside the pageload event, how do I do these without triggering this error? I have tried to remove the DatasourceID reference but then I cannot set it back without causing another error or else not getting it back to form level. Any ideas?

'Open up the connection

SQLConnection.Open()

'HERE WE NEED TO SET INITIAL GRIDVIEW VALUES
Gridview1.DataSource = Nothing
Gridview1.DataSourceID = Nothing
Gridview1.DataBind()
Dim dsGridViewData As DataSet = New DataSet
Dim daGridview As SqlDataAdapter = New SqlDataAdapter()

'GET ACTUAL BASE PERSON FROM SELECTED INDEX IN GRIDVIEW
Dim sqlStrGridView As String = "SELECT *" & _
"FROM TblDotNetAncestorsTree where uniqueID = '" & "12334546456" & "'"

daGridview = New SqlDataAdapter(sqlStrGridView, SQLConnection)
daGridview.Fill(dsGridViewData)

Gridview1.DataSource = dsGridViewData

Gridview1.DataSource = Nothing
Gridview1.DataSourceID = "SqlDataSourceGridView"

Here I would like to set it back so that it is usable at the form level, but its not working, any ideas?
coxmg is offline   Reply With Quote
Old 06-05-2012, 05:27 PM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
just don't set anything- if you are going to set anything set it's visibility to false... without the error messages or a clear explanation of what you are attempting will not be able to help. (what is it you're trying to do- I do not understand. What are the error messages?)
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:41 AM.


Advertisement
Log in to turn off these ads.