 |
| ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 3rd, 2009, 01:40 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Don't forget that C# is case sensitive, so it should probably be:
label1.Text = dr.GetString(dr.GetOrdinal("HomeLeft"));
Imar
|
|

March 3rd, 2009, 01:44 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Well.. I'm case insensitive.
Maybe that's why intellisense didn't help the OP?
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

March 3rd, 2009, 02:28 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
Thanks , can i ask u something?
i have 6 lablels that i need to bind, i am a bit wored about performance if i have to open 6 connections and close them that is not something i want to do, is there a way to do this under one connection? or use deferent controls that can do this in a lighter weight?
My table has 6 columns and 1 row i want to bind each column into labels/asp:conntrols
can i do it like this:
Code:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionString("Minds").ConnectionString);
SqlCommand cmdd = newSqlCommand("Select HomeLeft, Right, Centre from Home");
SqlDataReader dr = null;
cmdd.Connection = con;
con.Open();
dr = cmdd.ExecuteReader();
dr.Read();
if (dr.HasRows == true)
{
label1.Text = dr.GetString(dr.GetOrdinal("HomeLeft"));
label2.Text = dr.GetString(dr.GetOrdinal("Right"));
label3.Text = dr.GetString(dr.GetOrdinal("Centre"));.....
thanks
__________________
bx
|
|

March 3rd, 2009, 03:14 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The obvious answer is: "Have you tried it out"?
It looks good to me, and it should work like this...
Imar
|
|

March 3rd, 2009, 04:48 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
yes it worked that was write
__________________
bx
|
|

March 3rd, 2009, 04:51 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, you wrote: "can i do it like this:" implying you hadn't tried or tested it yet.
But then what is your question?
Imar
|
|

March 4th, 2009, 05:17 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
it sounds a bit silly , that was part of my question, what other controls can i use to achieve the same thing?
this time i am not gonna ask if i can use html labels before trying  .
__________________
bx
|
|

March 4th, 2009, 06:41 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
To achieve what? showing a text on screen?? anything that display a text :). Can you rephrase or think out load what are you expecting to accomplish?
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

March 4th, 2009, 09:34 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
|
|
It might be easier...
It might be easier to use a repeater control and a sqldatasource?
and just let them do all the work.
__________________
Jason Hall
Follow me on Twitter @jhall2013
|
|

March 4th, 2009, 09:36 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
well. OP only has 1 row with several columns. That's a nice idea if you have several rows.
That's why I ask him to think out loud, maybe we can understand what is he trying to do.
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
 |