Click here to Skip to main content
15,898,993 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Google map with multiple markers Pin
De_Novice8-Apr-11 11:32
De_Novice8-Apr-11 11:32 
QuestionWill you please post some code. Pin
Sheikh Sajid Ali5-Apr-11 20:20
Sheikh Sajid Ali5-Apr-11 20:20 
AnswerRe: Will you please post some code. Pin
Pete O'Hanlon6-Apr-11 2:19
mvePete O'Hanlon6-Apr-11 2:19 
QuestionRefresh Parent Window And Close Popup Window Pin
Orcun Iyigun5-Apr-11 15:09
Orcun Iyigun5-Apr-11 15:09 
Questiononly get one last record with the same field value during sorting database records Pin
Farhad Eft5-Apr-11 7:46
Farhad Eft5-Apr-11 7:46 
AnswerRe: only get one last record with the same field value during sorting database records Pin
Wendelius5-Apr-11 8:34
mentorWendelius5-Apr-11 8:34 
AnswerRe: only get one last record with the same field value during sorting database records Pin
Viral Upadhyay5-Apr-11 8:35
Viral Upadhyay5-Apr-11 8:35 
QuestionProblem with DropDownList and RequiredFieldValidator Pin
kbalias5-Apr-11 3:10
kbalias5-Apr-11 3:10 
Hi
In a Sql Server database we have a Patient table and a ReferHospital table. The ReferHospital table is a lookup table. There is a Foreign key column (RefHospID) in the Patient table.
In the past the Referring hospital was not a required input field, but it has become a required field for input recently.

I have a DetailsView on the page and I have made one of the fields a TemplateField. In the EditItemTemplate and InsertItemTemplate I have a DropdownList that is databound to the ReferringHospital table in the database.

So the two things I would like to achieve is:
1.) When an old patient record is loaded and the RefHospID field is null, the DropDownList must accept the null and display the initial value “- select -”.
2.) When a new patient is inserted (or an old patient edited) there must be a validation to check that the initial value “- select -” is not still selected, but that a RefHosp has been selected in the DropDownList.

I manage to get these two things working individually but not combined.

I set the AppendDataBoundItems property to true and added the initial value as a ListItem.

Markup of the DropdownList

<asp:DropDownList ID="DropDownList_HP" runat="server"
    AppendDataBoundItems="True" DataSourceID="SqlDataSource_RefHosp" 
    DataTextField="HospName" DataValueField="HospID" SelectedValue='<%# Bind("HospID") %>' Enabled="True">
    <asp:ListItem Selected="True" Value="">- select -</asp:ListItem>
</asp:DropDownList>                            


The code in bold is to enable the DropDownList to accept null values from the database. (This info I found at http://msdn.microsoft.com/en-us/library/ms366709.aspx )

I also added a RequiredFieldValidator to ensure that a value other than “- select -” is selected.

<asp:RequiredFieldValidator ID="RequiredFieldValidatorDV4" runat="server" 
    ControlToValidate="DropDownList_HP" 
    ErrorMessage="Select a referring hospital" 
    InitialValue="- select -" ValidationGroup="PatientInputGroupDV4"
SetFocusOnError="True"></asp:RequiredFieldValidator>                            


The problem is that without
Selected="True" Value=""
In the ListItem of the DropDownList an exception is thrown which says the DropDownList has “SelectedValue which is invalid because it does not exist in the list of items.”

And with
Selected="True" Value=""
The RequiredFieldValidator does not complain when ‘- select -’ is still selected when I want to update from the DetailsView.

Does anyone have any solutions for this problem.

Regards.

Kobus
AnswerRe: Problem with DropDownList and RequiredFieldValidator Pin
Not Active5-Apr-11 7:00
mentorNot Active5-Apr-11 7:00 
AnswerRe: Problem with DropDownList and RequiredFieldValidator Pin
Parwej Ahamad5-Apr-11 8:47
professionalParwej Ahamad5-Apr-11 8:47 
AnswerRe: Problem with DropDownList and RequiredFieldValidator Pin
Prasanta_Prince14-Apr-11 0:59
Prasanta_Prince14-Apr-11 0:59 
GeneralRe: Problem with DropDownList and RequiredFieldValidator Pin
kbalias27-Apr-11 21:06
kbalias27-Apr-11 21:06 
GeneralRe: Problem with DropDownList and RequiredFieldValidator Pin
Prasanta_Prince28-Apr-11 3:42
Prasanta_Prince28-Apr-11 3:42 
QuestionPaypal Tax Pin
Ramkumar_S5-Apr-11 2:28
Ramkumar_S5-Apr-11 2:28 
QuestionNeed help in implementing new skin for AuctionWorx Pin
NetMan20125-Apr-11 1:50
NetMan20125-Apr-11 1:50 
AnswerRe: Need help in implementing new skin for AuctionWorx Pin
Pete O'Hanlon5-Apr-11 2:33
mvePete O'Hanlon5-Apr-11 2:33 
QuestionAspx Login and Sql Server Problem - Help Me :( Pin
De_Novice4-Apr-11 10:01
De_Novice4-Apr-11 10:01 
AnswerRe: Aspx Login and Sql Server Problem - Help Me :( Pin
Wendelius4-Apr-11 10:15
mentorWendelius4-Apr-11 10:15 
AnswerRe: Aspx Login and Sql Server Problem - Help Me :( Pin
SamRST4-Apr-11 21:08
SamRST4-Apr-11 21:08 
QuestionPaypal testing.. Pin
Ramkumar_S4-Apr-11 1:09
Ramkumar_S4-Apr-11 1:09 
QuestionWhy this code does not run correctly on Linux server Pin
Abbas Fatshidi4-Apr-11 0:32
professionalAbbas Fatshidi4-Apr-11 0:32 
AnswerRe: Why this code does not run correctly on Linux server Pin
CodyDaemon4-Apr-11 1:39
CodyDaemon4-Apr-11 1:39 
QuestionHow can i copy html code to clipboard by using javascript? Pin
buffering833-Apr-11 20:10
buffering833-Apr-11 20:10 
AnswerRe: How can i copy html code to clipboard by using javascript? Pin
Ankur\m/3-Apr-11 21:14
professionalAnkur\m/3-Apr-11 21:14 
GeneralRe: How can i copy html code to clipboard by using javascript? Pin
buffering833-Apr-11 22:37
buffering833-Apr-11 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.