C# .NET - How we show record on webpage without using any server control

Asked By ALOK RANJAN on 24-May-12 07:33 AM
hi everyone ,
                    I have a scenario that I want to show record on web page without using any server control 
                    record should be show just like in gridview through which we can insert another record  on page.
                    please provide me solution.





Thank you 
Alok Ranjan 

                     
              
Somesh Yadav replied to ALOK RANJAN on 24-May-12 07:39 AM
check this,
http://www.dotnetspark.com/kb/1453-call-server-side-function-using-jquery-asp-net.aspx
Jitendra Faye replied to ALOK RANJAN on 24-May-12 07:56 AM

For this simply you can convert your DataSource to HTML table.


follow this code-


DataTable yourDataTable = yourDataSet.Tables[0];

 for (int i=0; i<yourDataTable.Rows.Count; i++)
 {
  DataRow currentDataRow = yourDataTable.Rows[i];

  TableRow newRow = new TableRow();

  for (int j=0; j<currentDataRow.Table.Columns.Count; j++)
  {
   // Create a Cell (<td>)...
   TableCell newCell = new TableCell();

   // Set some properties on the cell...
   newCell.BackColor = System.Drawing.Color.White;
   newCell.ForeColor = System.Drawing.Color.Black;

   // Add the text from the DataRow...
   newCell.Text = currentDataRow[j].ToString();

   // Add the cell to the row...
   newRow.Cells.Add(newCell);
  }

  // Add the row to the table:
  this.Table1.Rows.Add(newRow);
 }

TRy this and let em know.
dipa ahuja replied to ALOK RANJAN on 24-May-12 08:18 AM
void getReuslt()
  {
    SqlDataAdapter da = new SqlDataAdapter("select * from tabl1""connString");
    DataTable dt = new DataTable();
    da.Fill(dt);
 
    foreach (DataRow row in dt.Rows)
    {
      Response.Write("Name:" + row["name"] + "<br>");
      Response.Write("id:" + row["id"] + "<br>");
    }
  }