|
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
|
|
|
|
|
You could use a RangeValidator rather than a RequireFieldValidator. Assuming the selected value for the default item (-select-) is -1, set the MinimumValue attribute to 0 and the MaximumValue attribute to some number beyond the expected number of items, say 9999
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
As per my understanding and according to your dropdownlist value, initial value should be blank of Required field validator.
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDV4" runat="server"
ControlToValidate="DropDownList_HP"
ErrorMessage="Select a referring hospital"
InitialValue="" ValidationGroup="PatientInputGroupDV4"
SetFocusOnError="True"></asp:RequiredFieldValidator>
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
In required field validator set InitialValue="0" ;
Thank you.
|
|
|
|
|
Thank you prasanta_prince
In my RequiredFieldValidator I have set the InitialValue="" and it works great.
Regards.
Kobus
|
|
|
|
|
@kbalias, Good to know your problem is solved.
|
|
|
|
|
Hii All,
I am using below method to pass data to paypal.
"/
/ThankYou.aspx" />
" />
" />
Please help in calculating tax?
for singapore customer i need to charge 7%
Please help
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
Hi,
Is there any body who has done this before..??? how can i implement new skin in AuctionWorx.???
|
|
|
|
|
The best place for you to ask this is on the vendors support site[^]. It's highly unlikely that somebody cruising by the forum will just have happened to do this.
|
|
|
|
|
I have a weird problem:-
I have a two databases(A and B). Database A is used by the company's site and everything works fine. I created database B that uses the same user as Database A. I have created a base login site ( site B) using SQL membership provider in asp.net2.0 and this site connects to Database B, everything works fine locally but when I publish this site and upload it I cannot get the user log in.
1) I tired testing with the forgot password and I get the error "We were unable to access your information. Please try again. ". So I thought it was the web confog problem, to rule it out I changed the connection in siteB's web config to point to database A and it works fine. If I change the conection to dabase B it doesnt work.
2) I have added the application name setting too in the webconfig
Here is the web config:-
<connectionStrings>
<add name="dbconnection" connectionString="Data Source=SQLOLEDB.1;Data Source=.;Initial Catalog=DatabaseB;User ID=test;Password=test123"/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=SQLOLEDB.1;Data Source=.;Initial Catalog=DatabaseB;User ID=test;Password=test123"/>
</connectionStrings>
<system.web>
<roleManager enabled="true">
<providers>
<add name="SqlRoleManager"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="LocalSqlServer"
applicationName="/SiteB" />
</providers>
</roleManager>
<connectionStrings>
What am I doing wrong? Is there some permission that is not set in the new database. Its a basic SQL Server 2005 database and I used the aspnet sql tool to create the tables for the sql server membership.
Please help. I am stuck on this for over 72 hours.
|
|
|
|
|
One possibility is that the account is locked if you have tried to log in with wrong password for several times. Using Management Studio, open the login properties and see if it's locked (and of course if it is, unlock it ).
|
|
|
|
|
hi,
So with Database A you can connect and with DB B you cant. i hope its the problem with the permission of user to connect with DB B. Check the user permission for that DB. Go to managemt studio, take the Server logins, pick the user id, then check the permissions of that user to Database B. make sure, the user checked as db_owner. Good luck.
|
|
|
|
|
Hi All ,
I am using Paypal sandbox testing.
It is working fine, I still want to get the transaction status whether successful or failure only the payment is completed.
so I know paypal will return some hidden variables like "tx" to the successfull page.
My issue is I need to get the PDT token from sandbox.paypay.com,
But it is asking for the live url like www.test.com/sucess.aspx however i want to test in local url like http:\localhost:3030\sucess.aspx but not accepting.
so my question is how can i test in local url and generate token for local url..
Apologize if my communication is wrong.....
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
hello
Why this code does not run correctly on Linux server
<br />
TcpClient client = new TcpClient("www.zooo.ir", 80);<br />
NetworkStream stream = client.GetStream();<br />
byte[] send = Encoding.ASCII.GetBytes("GET /index.php HTTP/1.1 \r\n\r\n");<br />
stream.Write(send, 0, send.Length);<br />
byte[] bytes = new byte[client.ReceiveBufferSize];<br />
int count = stream.Read(bytes, 0, (int)client.ReceiveBufferSize);<br />
String data = Encoding.ASCII.GetString(bytes);<br />
char[] unused = { (char)data[count] };<br />
textBox1.Text = (data.TrimEnd(unused));<br />
stream.Close();<br />
client.Close();<br />
But IIS is working properly
<br />
TcpClient client = new TcpClient("www.codeproject.com", 80);<br />
NetworkStream stream = client.GetStream();<br />
byte[] send = Encoding.ASCII.GetBytes("GET /default.aspx HTTP/1.1 \r\n\r\n");<br />
stream.Write(send, 0, send.Length);<br />
byte[] bytes = new byte[client.ReceiveBufferSize];<br />
int count = stream.Read(bytes, 0, (int)client.ReceiveBufferSize);<br />
String data = Encoding.ASCII.GetString(bytes);<br />
char[] unused = { (char)data[count] };<br />
textBox1.Text = (data.TrimEnd(unused));<br />
stream.Close();<br />
client.Close();<br />
<code><br />
Please Help:confused:<br />
:((
|
|
|
|
|
At a guess, I would say due to the lack of HTTP headers. I think IIS is forgiving when you don't send all the headers.
|
|
|
|
|
I am now using below code.
But this code occur error when i copy html for example
<object type='application/x-shockwave-flash' id='MpE_lBcsBnw$' width='642px' height='390px' align='middle' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'><param name='movie' value='http://flvs.daum.net/flvPlayer.swf?vid=MpE_lBcsBnw$' /><param name='allowScriptAccess' value='always' /><param name='allowFullScreen' value='true' /><param name='bgcolor' value='#000000' /><param name='wmode' value='opaque' /><embed src='http://flvs.daum.net/flvPlayer.swf?vid=MpE_lBcsBnw$' width='642px' height='390px' allowScriptAccess='always' type='application/x-shockwave-flash' allowFullScreen='true' bgcolor='#000000' ></embed></object>
How can i copy html code to clipboard by using javascriptcode?
<script type="text/javascript">
function setClip() {
window.clipboardData.setData('Text', '<%=CLIPCOPY%>');
alert('<%=CLIPCOPY%>' + 'was copyied.');
}
</script>
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
|
Thank you!
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
I've been working on this web chat application Build a Web Chat Application using ASP.Net 3.5, LINQ and AJAX (in C# 3.5 or VB 9.0)[^]
but there's always a problem i tried a lot to solve but no hope which is : i have specific rooms and each room is specified to certain users so that users in one room can talk together without people in other rooms can see them but the problem is that users enter wrong rooms ! although they are directed to the right room but their names are added to the wrong room list !! i used the same code as in the link before and i tested it and it has the same problem ! ... please anyone help me
|
|
|
|
|
Hi Dear, It would better and for response you have to post your query on article discussion section (Go to below of article page).
Thanks
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
When you use webclient.DownloadFile("http://www.whatismyip.com/automation/n09230945.asp", tempfile) you get a file that contains only a string (the ip address) and no page source text.
I want to create an application that similarly sends only a simple string when the client accesses the server url.
How?
|
|
|
|
|
This would typically be implemented as a web service but in an asp.net page you would use Response.Write[^], and related methods to place data in the output stream.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
OK, here's my page source:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetIP.aspx.cs" Inherits="TestResponse._GetIP" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" ><br />
<head runat="server"><br />
<title></title><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<div> </div><br />
</form><br />
</body><br />
</html>
And, here's my code behind:
protected void Page_Load(object sender, EventArgs e)
{
string ipAddress = null;
ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipAddress == null)
{
ipAddress = Request.ServerVariables["REMOTE_ADDR"];
}
Response.Write(ipAddress);
}
Here's a function in a C# application that gets the data from a site:
protected internal static string scrapeIP(string fromUrl)
{
string result=string.Empty;
WebClient wc = new WebClient();
result = wc.DownloadString(fromUrl);
return result;
}
When fromUrl = "http://www.whatismyip.com/automation/n09230945.asp", the result is: "xxx.xxx.xxx.xxx"
When fromUrl = "http://www.mySite/GetIP.aspx", the result is:
"xxx.xxx.xxx.xxx \r\n\r\n\r\n\r\n\r\n<title>\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n"
I want my site to send just the IP address (like whatismyip.com/automation.....) That is, when I execute my C# function from a separate application, the returned result is just the client's external IP address.
Any ideas?
|
|
|
|
|
It should be evident from the output you have. The Response object is filled with the necessary bits that tell the browser this is a webpage, such as the DOCTYPE, html, body. Response.Write(ipAddress) just adds to the stream it does nothing to replace it. What you need to do is, as I said before, use some of the other methods of the HttpResponse class, like ClearContent[^]
Also, again as I said before, this really should be implemented as a web service. Just because some other site is doing it as a webpage doesn't mean its the best way. Look at the URL and you will see it is using asp, a severly outdated technology.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi, i'm trying to access the SQL Report in asp.net reportviewer. i had successfully configured Sql Report service 2008 and the report manager is working fine. But when i try open the reports in asp.net page with reportviewer it shows "The request failed with HTTP status 401: Unauthorized". i'm passing the credentials parameter in config file and the reportserver Network credential class is also working fine. Can anybody help me please... i tired with googling...
Thanks in advance....
|
|
|
|