Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Function Returns Empty DataSet

Reply
Thread Tools

Re: Function Returns Empty DataSet

 
 
Goofy
Guest
Posts: n/a
 
      12-12-2006

You need to DataBind your dropdown box.

ddCats.DataBind



"Erica" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a drop down list named ddCats. It's datasource is a public function
> called GetCatagories(). Here is the code for the function:
>
> Public Function GetCategories() As DataSet
> Dim myAuthenticate As New myAuth
> Dim myConn As New
> MySql.Data.MySqlClient.MySqlConnection(myAuthentic ate.DecryptConnectionString)
> myConn.Open()
> 'Populate the ddlDataSet
> Const strSQLDDL As String = "select lookup_value,lookup_id,ShortName from
> lookup where lookup_id = 'categoryID'"
> Dim myDataAdapter As New
> MySql.Data.MySqlClient.MySqlDataAdapter(strSQLDDL,
> myConn)
> myDataAdapter.Fill(ddlDataSet, "Categories")
> Return ddlDataSet
> End Function
>
> ddlDataSet is declared as a global variable.
>
> Why is the drop down list showing up empty. The select statement when ran
> directly against the mySql table returns 4 records. Here is the relevant
> HTML:
>
> <aspropDownList id=ddCats runat="server" Visible="False" Width="158px"
> DataTextField="ShortName" DataValueField="lookup_value" DataSource="<%#
> GetCategories() %>"></aspropDownList>
>
> Why is the dropdownlist empty when it is displayed?



 
Reply With Quote
 
 
 
 
Goofy
Guest
Posts: n/a
 
      12-12-2006

You can put the databind statement directly after you set the DataSource if
you want, alternatively you can put a catchall DataBind to bind the whole
page in the pre-render event.


"Erica" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Goofy. That's exactly where I was missing it. One other question.
> Where's the best place to put the databind. I have a couple of different
> dropdowns that are auto populated and a datagrid. Should I put it in the
> Page
> Load event?
>
> "Goofy" wrote:
>
>>
>> You need to DataBind your dropdown box.
>>
>> ddCats.DataBind
>>
>>
>>
>> "Erica" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have a drop down list named ddCats. It's datasource is a public
>> >function
>> > called GetCatagories(). Here is the code for the function:
>> >
>> > Public Function GetCategories() As DataSet
>> > Dim myAuthenticate As New myAuth
>> > Dim myConn As New
>> > MySql.Data.MySqlClient.MySqlConnection(myAuthentic ate.DecryptConnectionString)
>> > myConn.Open()
>> > 'Populate the ddlDataSet
>> > Const strSQLDDL As String = "select lookup_value,lookup_id,ShortName
>> > from
>> > lookup where lookup_id = 'categoryID'"
>> > Dim myDataAdapter As New
>> > MySql.Data.MySqlClient.MySqlDataAdapter(strSQLDDL,
>> > myConn)
>> > myDataAdapter.Fill(ddlDataSet, "Categories")
>> > Return ddlDataSet
>> > End Function
>> >
>> > ddlDataSet is declared as a global variable.
>> >
>> > Why is the drop down list showing up empty. The select statement when
>> > ran
>> > directly against the mySql table returns 4 records. Here is the
>> > relevant
>> > HTML:
>> >
>> > <aspropDownList id=ddCats runat="server" Visible="False" Width="158px"
>> > DataTextField="ShortName" DataValueField="lookup_value" DataSource="<%#
>> > GetCategories() %>"></aspropDownList>
>> >
>> > Why is the dropdownlist empty when it is displayed?

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
function call from unmanaged code returns empty string - HELP!!!! Joe ASP .Net Security 3 02-19-2009 10:23 PM
Sorted Returns List and Reversed Returns Iterator ++imanshu Python 7 08-23-2008 04:25 AM
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
block returns and hash element returns Trans Ruby 2 11-06-2005 12:15 PM
can javascript function consume webservice that returns ado.net dataset? Timo ASP .Net Web Services 2 01-10-2004 12:58 PM



Advertisments