Solved

Dropdownlist in Footer...

Posted on 2007-04-10
10
237 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 500 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Greetings C# program 17 104
Importing CSV file encoded in UTF-8 in SQL SERVER 2008 using BULK INSERT 5 48
Service Controller 1 23
Problem!!! 8 33
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now