Click here to Skip to main content
15,887,267 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: asp.net 2010 validate dates Pin
jkirkerx21-Jul-12 18:49
professionaljkirkerx21-Jul-12 18:49 
Generalmultipe forms in same page Pin
Jassim Rahma20-Jul-12 7:08
Jassim Rahma20-Jul-12 7:08 
GeneralRe: multipe forms in same page Pin
R. Giskard Reventlov20-Jul-12 8:03
R. Giskard Reventlov20-Jul-12 8:03 
GeneralRe: multipe forms in same page Pin
Parwej Ahamad20-Jul-12 8:28
professionalParwej Ahamad20-Jul-12 8:28 
Questionurlrewriter.net Problem Pin
Jassim Rahma20-Jul-12 0:28
Jassim Rahma20-Jul-12 0:28 
AnswerRe: urlrewriter.net Problem Pin
AmitGajjar23-Jul-12 1:04
professionalAmitGajjar23-Jul-12 1:04 
AnswerRe: urlrewriter.net Problem Pin
_Amy23-Jul-12 1:36
professional_Amy23-Jul-12 1:36 
QuestionProblem: Popolating HTML Table Dynamically Pin
silentcore19-Jul-12 22:28
silentcore19-Jul-12 22:28 
XML
Hi There.
I am having a problem in populating html table from database dynamically. What i mean is that i

have a table in database that have let say 10 enteries, I want to display those 10 entries in a

html table using loop. I am new to ASP.NET, I've previously woked in php. I can present the

scenario in php and please help me do the same thing in ASP.NET. In php what i normally do is

search the database, grab the table in fetch array and in html table i create one row and use

while loop so that all of the 10 entries are populated at runtime. Here is a demonstration

code in head:


   <pre lang="PHP"><?php
           $query = mysql_query("select * from table");
           ?>


in body code:

HTML
<table>
            <tr>
            <td>Username</td>
            <td>Email</td>
            <td>Position</td>
            <td>Status</td>
            </td>
            //start of the loop
            <?php while($fetch = mysql_fetch_array($query) { ?>
            <tr>
            <td><?php echo $fetch["username"]; ?> </td>
            <td><?php echo $fetch["email"]; ?> </td>
            <td><?php echo $fetch["position"]; ?> </td>
            <td><?php echo $fetch["status"]; ?> </td>
            </tr><?php } ?>//End of loop
            </table>






When i use foreach loop in asp.net to do the same thing the it displays only the last row in the

database table...I am using three tier architecture...



C#
projectsLoad_BLL bo = new projectsLoad_BLL();

                      DataSet ds = new DataSet();
                      DataTable dt = ds.Tables[0];
                      int num = 1;
                      foreach (DataRow dr in dt.Rows)
                      {
                          lblno.Text = num.ToString();
                          lblusername.Text = dr["username"].ToString();
                          lblemail.Text = dr["email"].ToString();
                          lblposition.Text = dr["position"].ToString();
                          lblstatus.Text = dr["status"].ToString();
                          dt.NewRow();
                          num++;
                      }





In HTML Table:


ASP.NET
 <table>
               <thead>
                    <tr>
                    <th>No.</th>
                    <th>Username</th>
                    <th>Email</th>
                    <th>Position</th>
                     <th>Status</th>
                      </tr>
                        </thead>
                             <tbody>
                                <tr>
                                   <td><asp:Label ID="lblno" runat="server"

Text="Label"></asp:Label> </td>
                                   <td><asp:Label ID="lblusername" runat="server"

Text="Label"></asp:Label></td>
                                   <td><asp:Label ID="lblemail" runat="server"

Text="Label"></asp:Label></td>
                                   <td><asp:Label ID="lblposition" runat="server"

Text="Label"></asp:Label></td>
                                   <td><asp:Label ID="lblstatus" runat="server"

Text="Label"></asp:Label></td>
                                               </tr>
                                           </tbody>
                                       </table>




I know that this method is wrong...if anyone can point to the right direction...thanks in

advance
AnswerRe: Problem: Popolating HTML Table Dynamically Pin
Pankaj Nikam20-Jul-12 4:07
professionalPankaj Nikam20-Jul-12 4:07 
GeneralRe: Problem: Popolating HTML Table Dynamically Pin
silentcore5-Aug-12 8:25
silentcore5-Aug-12 8:25 
GeneralRe: Problem: Popolating HTML Table Dynamically Pin
Pankaj Nikam5-Aug-12 14:46
professionalPankaj Nikam5-Aug-12 14:46 
GeneralRe: Problem: Popolating HTML Table Dynamically Pin
jkirkerx20-Jul-12 7:47
professionaljkirkerx20-Jul-12 7:47 
GeneralRe: Problem: Popolating HTML Table Dynamically Pin
Eone James23-Jul-12 23:23
Eone James23-Jul-12 23:23 
QuestionASP.net Control Pin
safi belim19-Jul-12 5:31
safi belim19-Jul-12 5:31 
AnswerRe: ASP.net Control Pin
R. Giskard Reventlov19-Jul-12 5:39
R. Giskard Reventlov19-Jul-12 5:39 
GeneralRe: ASP.net Control Pin
safi belim19-Jul-12 7:06
safi belim19-Jul-12 7:06 
GeneralRe: ASP.net Control Pin
R. Giskard Reventlov19-Jul-12 7:22
R. Giskard Reventlov19-Jul-12 7:22 
QuestionWhat is ref and out and how to use in asp.net ? Pin
NeerajYadavMca2k518-Jul-12 21:23
NeerajYadavMca2k518-Jul-12 21:23 
AnswerRe: What is ref and out and how to use in asp.net ? Pin
Richard MacCutchan18-Jul-12 22:07
mveRichard MacCutchan18-Jul-12 22:07 
AnswerRe: What is ref and out and how to use in asp.net ? Pin
Sandeep Mewara18-Jul-12 22:39
mveSandeep Mewara18-Jul-12 22:39 
AnswerRe: What is ref and out and how to use in asp.net ? Pin
ashjassi17-Aug-12 2:55
ashjassi17-Aug-12 2:55 
QuestionSMPT server not sent an Email to gmail or yahoo mails Pin
Muhammad Fahim Baloch18-Jul-12 19:57
Muhammad Fahim Baloch18-Jul-12 19:57 
AnswerRe: SMPT server not sent an Email to gmail or yahoo mails Pin
Rajesh Buddaraju19-Jul-12 6:15
Rajesh Buddaraju19-Jul-12 6:15 
AnswerRe: SMPT server not sent an Email to gmail or yahoo mails Pin
jkirkerx19-Jul-12 8:19
professionaljkirkerx19-Jul-12 8:19 
AnswerRe: SMPT server not sent an Email to gmail or yahoo mails Pin
phani.sv21-Jul-12 0:37
phani.sv21-Jul-12 0: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.