[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 764
  • Last Modified:

template field with dropdownlist and datasource

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
AmyL
Asked:
AmyL
  • 4
  • 2
1 Solution
 
Rahul AgarwalTeam LeaderCommented:
0
 
AmyLAuthor Commented:
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
 
Rahul AgarwalTeam LeaderCommented:
put in try catch block so when the error occurs then it goes to catch block. May be it solves your problem.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
AmyLAuthor Commented:
It isn't in code, it is in the markup:
SelectedValue='<%# Bind("contentBanner") %>'
0
 
informaniacCommented:
Yet I think u shd be able to check in RowDatabound evnt of the gridview.
0
 
AmyLAuthor Commented:
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
 
AmyLAuthor Commented:
Thanks - I'll ask the rest in another question.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now