Solved

Dropdownlist in Footer...

Posted on 2007-04-10
10
241 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

635 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