Solved

Dropdownlist in Footer...

Posted on 2007-04-10
10
235 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

13 Experts available now in Live!

Get 1:1 Help Now