Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

template field with dropdownlist and datasource

Posted on 2011-03-02
7
Medium Priority
?
751 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
[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
  • 4
  • 2
7 Comments
 
LVL 13

Accepted Solution

by:
Rahul Agarwal earned 1000 total points
ID: 35023836
0
 

Author Comment

by:AmyL
ID: 35023986
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:Rahul Agarwal
ID: 35024044
put in try catch block so when the error occurs then it goes to catch block. May be it solves your problem.
0
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

 

Author Comment

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

Expert Comment

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

Author Comment

by:AmyL
ID: 35027257
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
ID: 35065950
Thanks - I'll ask the rest in another question.
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

718 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