Solved

template field with dropdownlist and datasource

Posted on 2011-03-02
7
738 Views
Last Modified: 2012-08-14
I have a gridview with a template field that contains a dropdownlist. I would like to set the datasource for this dropdownlist to be either a comma delimited list or the return of the getFiles()  function (whichever is easier). Can someone please tell me how to do this?

Thanks!
Amy
0
Comment
Question by:AmyL
  • 4
  • 2
7 Comments
 
LVL 13

Accepted Solution

by:
agarwalrahul earned 250 total points
Comment Utility
0
 

Author Comment

by:AmyL
Comment Utility
That is almost exactly right...I just need one last piece:

Since the datasource is based on a file listing, the selected value of the dropdownlist may no longer exist (for instance, in the event the file was removed). Right now, when that happens, I get this error:

-----------------------------------------------------
dropdownlist1 has a SelectedValue which is invalid because it does not exist in the list of items
-----------------------------------------------------

Is there a way to keep the dropdownlist bound, but allow it to bypass this error in the event that the file no longer exists?

Thanks!
Amy
0
 
LVL 13

Expert Comment

by:agarwalrahul
Comment Utility
put in try catch block so when the error occurs then it goes to catch block. May be it solves your problem.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:AmyL
Comment Utility
It isn't in code, it is in the markup:
SelectedValue='<%# Bind("contentBanner") %>'
0
 
LVL 20

Expert Comment

by:informaniac
Comment Utility
Yet I think u shd be able to check in RowDatabound evnt of the gridview.
0
 

Author Comment

by:AmyL
Comment Utility
This is a bigger problem than I thought. I am getting this error even when the file does exist...probably because of the timing in creating the datasource on rowbind.

Since it is one dataset with no parameters, I'm thinking it might be better to create an ObjectDatasource and bind to that. Do you know how to do that?
0
 

Author Closing Comment

by:AmyL
Comment Utility
Thanks - I'll ask the rest in another question.
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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

9 Experts available now in Live!

Get 1:1 Help Now