Try - Catch

J

Jim McGivney

In VWD I have an aspx page with a detailsview tied into a gridview for a
Master-Detail page.
I make one of the detailsview fields (the race field) a template field. On
the EditItem template I replace the text box with a DropDownList. This all
works fine until a record is selected with a value in the race field that is
not one of the items on the DropDownList, a error is thrown when the EDIT
button is clicked, saying the value is not on the list.
I would like to trap this error but do not know where or how. If I double
click the EDIT button, the event argument "
DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)"
is displayed. I do not know what to place in the try or catch expressions.

Sample code would be appreciated.

Thanks in advance for your help,

Jim
 
N

Neutrino

Hello Jim,

An alternative to trapping the error is to prevent it from happening.
You may be able to add the non existing value to the dropdownlist (by
adding a ListItem) to the Items collection of the control during the
DataBinding Event of the dropdownlist control. The difficult part may
be to determine what is the new value to be added. Probably the
"sender" parameter of the event contains a reference to the GridViewRow
that is being bound and with the DataItem property you can get to the
value(s) you need to add. Sorry, if this is not very complete, but I
hope at least works as a hint. Good luck!

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top