Solved

Dropdownlist in Footer...

Posted on 2007-04-10
10
239 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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