Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dropdownlist in Footer...

Posted on 2007-04-10
10
Medium Priority
?
242 Views
Last Modified: 2010-05-19
Hi there,

I have a gridview footer and I want to populate a dropdownlist with data from an sql database which is in the footer and I have no idea how I would do this... help is appriciate..

Stelly
0
Comment
Question by:stellyuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 

Author Comment

by:stellyuk
ID: 18881939
I have tried this with no joy... its not populating the dropdownlist
    protected void FooterInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DataSet DropInfo = SQLQueries.AvailSoftware();

            DropDownList soft = (DropDownList)e.Row.FindControl("DropDownListSoft");

            soft.DataSource = DropInfo;
            soft.DataTextField = "SoftwareName";
            soft.DataValueField = "SoftwareName";
            soft.DataBind();
        }
    }

Can anyone help me??

Stelly
0
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18882485
Make sure that you set the DataMember of the dropdownlist when you are setting the DataSource as a DataSet.  If the DataSource is a DataTable you don't need to set the DataMember but if it is a DataSource you generally need to set the DataMember as the tablename of the data table within the DataSet.
0
 

Author Comment

by:stellyuk
ID: 18883198
Can you give an example please??

Stelly
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Expert Comment

by:CBeach1980
ID: 18883258
Assuming that the name of the DataTable within the DataSet is "AvailableSoftware" then the following:

    protected void FooterInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DataSet DropInfo = SQLQueries.AvailSoftware();
            DropDownList soft = (DropDownList)e.Row.FindControl("DropDownListSoft");
            soft.DataSource = DropInfo;
            soft.DataMember = "AvailableSoftware";
            soft.DataTextField = "SoftwareName";
            soft.DataValueField = "SoftwareName";
            soft.DataBind();
        }
    }
0
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18883283
If you don't know the name of the datatable and there is only one returned as part of the DataSet from SQLQueries.AvailSoftware() then you could also do:

soft.DataMember = DropInfo.Tables[0].TableName;

but this is not as robust as manually setting the tablename when you populate the DataSet.  In SQLQueries.AvailSoftware() if you populate the DataSet from a DataAdapter you can use:

dataAdapter.Fill(dataSet, "TableName");
0
 

Author Comment

by:stellyuk
ID: 18888205
didnt work :(

Stelly
0
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18890570
In debug mode have you verified that the DataSet is getting populated and that you have the correct tablename?
0
 

Author Comment

by:stellyuk
ID: 18918166
yes it does pass data...

Any ideas??

Stelly
0
 
LVL 4

Accepted Solution

by:
CBeach1980 earned 1500 total points
ID: 18935556
I am for the most part stumped.  Have you tried manually adding an item inside of the function to verify there isn't something weird going on with the dropdownlist itself?
0
 

Author Comment

by:stellyuk
ID: 18956780
Its ok I have sorted it now... you gave some great help so I will give you the points :)

Stelly
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question