954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP.NET, referring to a DataSet within script

I am using ASP.NET, and the ASP.NET WebMatrix program, latest version. I am writing a page that is supposed to check the username someone has entered into a textbox against the list of users from the database, so that two people can't have the same username. Simple, right? Not when you're me.

I know what I'd like to do, I just have no idea how to write the following in ASP.NET. This is the pseudo-code for it.
"If txtUserName.Text = Currently Selected Record.Username then"

I can put a in the code and use <%#Container.DataItem("Username")%> to print the Username which is great, but that doesn't work within the

fortheloveof
Newbie Poster
2 posts since Dec 2004
Reputation Points: 10
Solved Threads: 0
 

...well I solved that one.

The necessary code was simply this:

While dataReader.Read()
                 if dataReader("Username") = txtUsername.Text then
                     label1.Text = "Username is already taken!"
                 end if
             End While

This .Read() fiasco apparently replaced the old .MoveNext from regular ASP. When there are items left, .Read() will return "True". Otherwise, i.e. when there are no more records, it will return "False"... hence the while loop.

This is why I hate computers. ;)

fortheloveof
Newbie Poster
2 posts since Dec 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You