Display within a loop

Last post 06-25-2008 7:25 AM by GillouX. 7 replies.

Sort Posts:

  • Display within a loop

    06-23-2008, 6:36 PM
    • Loading...
    • chiraajeet_de
    • Joined on 06-23-2008, 10:20 PM
    • INDIA
    • Posts 7

    Can Anyone please show me how to implement the same type of funtionality, shown i the code below, in asp.net 2.0?

    PLease send me the procedure to get the thing done in vs2005. Or just the code will do for the .aspx &.aspx.cs.

    Hope to get some needed reply soon.

    Thank You

     

    <?php

    $sql="select * from table";
    $query=mysql_query($sql) or die("Query failed : " . mysql_error());
    $row=mysql_fetch_array($query);


    ?>


    <td width="501" valign="top">
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="999" height="25" align="center" valign="middle"><?php print $_SESSION['msg'];$_SESSION['msg']=""; ?></td>
      </tr>
    </table>
      <?php do { ?>
     <div align="center"><table width="100%" border="0" cellpadding="0" cellspacing="0">
            <!--DWLayoutTable-->
            <tr>
              <td width="114" height="25" align="right" valign="middle"><strong>Question-<?php echo $row['id'];?> :</strong></td>
              <td width="11" align="left" valign="middle"><!--DWLayoutEmptyCell-->&nbsp;</td>
            <td colspan="4" align="left" valign="middle"><?php echo $row['question'];?></td>
            </tr>
            <?php if ($row['type']=="MC") { ?>
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Option1 :</strong></td>
              <td colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td width="819" align="left" valign="middle"><?php echo $row['option1'];?></td>
            </tr>
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Option2 :</strong></td>
             <td colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td align="left" valign="middle"><?php echo $row['option2'];?></td>
            </tr>
           
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Option3 :</strong></td>
             <td width="5" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td width="5">&nbsp;</td>
              <td align="left" valign="middle"><?php echo $row['option3'];?></td>
            </tr>
           
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Option4 :</strong></td>
              <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td>&nbsp;</td>
              <td align="left" valign="middle"><?php echo $row['option4'];?></td>
            </tr>
            <?php } else if ($row['type']=="TF") { ?>
      
          <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Option1 :</strong></td>
              <td colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td width="819" align="left" valign="middle"><?php echo $row['option1'];?></td>
            </tr>
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Option2 :</strong></td>
             <td colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td align="left" valign="middle"><?php echo $row['option2'];?></td>
            </tr>
           
           
      <?php } ?>
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>Right Option :</strong></td>
              <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td>&nbsp;</td>
              <td align="left" valign="middle"><?php echo $row[$row['right_opt']];?></td>
            </tr>
            <tr>
              <td height="25" colspan="3" align="right" valign="middle"><strong>QuestionType :</strong></td>
              <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
              <td>&nbsp;</td>
              <td align="left" valign="middle"><?php echo $row['type'];?></td>
            </tr>
            <tr>
              <td height="25" colspan="6" align="center"><a href="del_question.php?id=<?php echo $row['id'];?>">Delete</a> / <a href="edit_question.php?id=<?php echo $row['id'];?>">Edit</a></td>
            </tr>
            <tr>
              <td height="1"></td>
              <td></td>
              <td width="45"></td>
              <td></td>
              <td></td>
              <td></td>
            </tr>
      </table></div>
    <?php $qno=$qno+1;} while ($row=mysql_fetch_array($query)) ;  ?>

  • Re: Display within a loop

    06-24-2008, 4:16 AM
    • Loading...
    • GillouX
    • Joined on 06-03-2007, 11:28 AM
    • Luxemburg
    • Posts 381

     I won't give you all the code, just a piece of solution

     

    use a gridview that you will populate using a dataset.

     

    gridview.datasource = yourdataset;

    gridview.databinding();

    here how to create your dataset

    http://www.exforsys.com/tutorials/asp.net/managing-data-with-ado.net-datasets-and-csharp.html

     

    have fun

     

    if you have any questions, feel free to ask 

  • Re: Display within a loop

    06-25-2008, 5:23 AM
    • Loading...
    • chiraajeet_de
    • Joined on 06-23-2008, 10:20 PM
    • INDIA
    • Posts 7

    Thanks!!!!

    I had already tried with Grid view. With grid view i can do the thing but the records are shown row wise but i need to show column wise. To explain it better, please be kind enough to visit this link: onlineexam.runhost.net/admin username: master & pass: admin then click "View Questions". That is the way i want the records to be shown. ok? As I told you, with grid view i am able to do along with edit and delete. Or you could please tell me the way to show the records, column wise in grid view.

    Thanks a lot again!!!!

  • Re: Display within a loop

    06-25-2008, 5:41 AM
    • Loading...
    • GillouX
    • Joined on 06-03-2007, 11:28 AM
    • Luxemburg
    • Posts 381

     so you shoud use instead a datalist and set the repeat direction

     

  • Re: Display within a loop

    06-25-2008, 5:53 AM
    • Loading...
    • chiraajeet_de
    • Joined on 06-23-2008, 10:20 PM
    • INDIA
    • Posts 7

    Yeah data list is showing the records the way i wanted but i am not able to find a way to add edit and delete features to it. How can I add edit and delete button to a data list using VS2005.

    Can u please help me with that?

    Thanks!!!!!!!!

  • Re: Display within a loop

    06-25-2008, 6:02 AM
    • Loading...
    • GillouX
    • Joined on 06-03-2007, 11:28 AM
    • Luxemburg
    • Posts 381

     you can find easily info about this on Internet

     

    for instance here

    http://sureshsharmaaspdotnet.wordpress.com/2008/05/15/editupdate-and-delete-in-datalist/

    or

     

    here

    http://www.asp.net/Learn/Data-Access/tutorial-46-vb.aspx

     

    gl 

     

  • Re: Display within a loop

    06-25-2008, 6:20 AM
    • Loading...
    • chiraajeet_de
    • Joined on 06-23-2008, 10:20 PM
    • INDIA
    • Posts 7

    Thanks Dude!!! This will help me a lot

  • Re: Display within a loop

    06-25-2008, 7:25 AM
    • Loading...
    • GillouX
    • Joined on 06-03-2007, 11:28 AM
    • Luxemburg
    • Posts 381

     there aren't much free hostsfor asp.net

     

    but it's one of them that I used lately

     

    http://www.aspspider.com/

     

Page 1 of 1 (8 items)
Microsoft Communities
Page view counter