Solved

template field with dropdownlist and datasource

Posted on 2011-03-02
7
744 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
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:agarwalrahul
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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