Click here to Skip to main content
15,885,309 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionAccessing the selectedIndex of a dynamically created Dropdownlist... Pin
Radiv Jeshya4-May-09 0:25
Radiv Jeshya4-May-09 0:25 
AnswerRe: Accessing the selectedIndex of a dynamically created Dropdownlist... Pin
saanj4-May-09 1:26
saanj4-May-09 1:26 
AnswerRe: Accessing the selectedIndex of a dynamically created Dropdownlist... Pin
Uma J5-May-09 0:40
Uma J5-May-09 0:40 
QuestionCart application Pin
Rajesh Kumar Chekuri4-May-09 0:20
Rajesh Kumar Chekuri4-May-09 0:20 
AnswerRe: Cart application Pin
Rajesh Kumar Chekuri4-May-09 2:26
Rajesh Kumar Chekuri4-May-09 2:26 
GeneralRe: Cart application Pin
MidwestLimey4-May-09 5:20
professionalMidwestLimey4-May-09 5:20 
QuestionGet multiple data from table and show in different label boxes Pin
scothykonma4-May-09 0:16
scothykonma4-May-09 0:16 
AnswerRe: Get multiple data from table and show in different label boxes Pin
saanj4-May-09 1:39
saanj4-May-09 1:39 
Hi,
You have told that you are using three or more label controls to display three rows picked from the database tables. As far as the code that you have posted, you have started a for loop and it binds the value with the lblMessage control. So it is pretty clear that the value which is getting bound to the lblMessage control, is getting overwritten each time the for loop runs. So at the end of the loop execution, the label is showing the last result only. Frown | :(

Suppose, you have three controls like lblMessage1, lblMessage2 and lblMessage3. To achieve the functionality referred by you, just try the following code:

for (i = 0; i<= obj.Tables[0].Rows.Count - 1; i++)
{
if(i==0)
{
string text1 = obj.Tables[0].Rows[i]["id"].ToString();
string text2 = obj.Tables[0].Rows[i]["Name"].ToString();
lblMessage1.Text = text1 + " " + text2;
}
if(i==1)
{
string text1 = obj.Tables[0].Rows[i]["id"].ToString();
string text2 = obj.Tables[0].Rows[i]["Name"].ToString();
lblMessage2.Text = text1 + " " + text2;
}
else
{
string text1 = obj.Tables[0].Rows[i]["id"].ToString();
string text2 = obj.Tables[0].Rows[i]["Name"].ToString();
lblMessage3.Text = text1 + " " + text2;
}
}

All the best. Smile | :)

Either you love IT or leave IT...

GeneralRe: Get multiple data from table and show in different label boxes Pin
scothykonma4-May-09 3:46
scothykonma4-May-09 3:46 
GeneralRe: Get multiple data from table and show in different label boxes Pin
saanj4-May-09 18:45
saanj4-May-09 18:45 
AnswerRe: Get multiple data from table and show in different label boxes Pin
Uma J5-May-09 0:46
Uma J5-May-09 0:46 
QuestionHow to tigger updatePanel by a textbox event? Pin
dev sheoran3-May-09 23:55
dev sheoran3-May-09 23:55 
AnswerRe: How to tigger updatePanel by a textbox event? Pin
Abhijit Jana4-May-09 0:49
professionalAbhijit Jana4-May-09 0:49 
AnswerRe: How to tigger updatePanel by a textbox event? Pin
saanj4-May-09 1:42
saanj4-May-09 1:42 
Questionrestrict the user from any action during an web request in asp.net 2.0 Pin
bikash pattanayak3-May-09 23:53
bikash pattanayak3-May-09 23:53 
AnswerRe: restrict the user from any action during an web request in asp.net 2.0 Pin
Abhijit Jana4-May-09 0:43
professionalAbhijit Jana4-May-09 0:43 
AnswerRe: restrict the user from any action during an web request in asp.net 2.0 Pin
saanj4-May-09 1:44
saanj4-May-09 1:44 
QuestionLocalization and Globalization Pin
Member 42532763-May-09 23:31
Member 42532763-May-09 23:31 
AnswerRe: Localization and Globalization Pin
Christian Graus3-May-09 23:49
protectorChristian Graus3-May-09 23:49 
GeneralRe: Localization and Globalization Pin
Abhijit Jana4-May-09 0:40
professionalAbhijit Jana4-May-09 0:40 
Questionvalidation on dropdown list Pin
mdazeemuddin3-May-09 23:23
mdazeemuddin3-May-09 23:23 
AnswerRe: validation on dropdown list Pin
Abhijit Jana3-May-09 23:25
professionalAbhijit Jana3-May-09 23:25 
Answervalidation on dropdown list Pin
Member 42532763-May-09 23:39
Member 42532763-May-09 23:39 
GeneralRe: validation on dropdown list Pin
mdazeemuddin5-May-09 0:15
mdazeemuddin5-May-09 0:15 
AnswerRe: validation on dropdown list Pin
saanj4-May-09 1:47
saanj4-May-09 1:47 

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.