Codeasearch.com - Search your code with us Login | Register | Contact us
  Forums > Asp.Net > creating tr and td in runtime using csharp
forums_reader
Posted on Jul 20, 2007
Join Date: July 2007
Location: India ( Chennai )
Posts: 24
 
creating tr and td in runtime using csharp  

Save the file as Demo.aspx
----------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Demo.aspx.cs" Inherits="Demo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="frmMyFrom" runat="server">
<asp:Table ID="tblSample" runat="server">
</asp:Table>
</form>
</body>
</html>
------------------End Here-------------------


Code behind page
----------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
RunTimeTable();
}

private void RunTimeTable()
{
string[] myString = { "one", "two", "three", "four" };
for (int icnt = 0; icnt <= myString.Length - 1; icnt++)
{
TableRow tRow = new TableRow();
tblSample.Rows.Add(tRow);

TableCell tCell = new TableCell();
tRow.Cells.Add(tCell);

tCell.Controls.Add(new LiteralControl(myString[icnt]));
}


}

 Hot Discussion
Go Tech launches Android tablet for Rs 3,999...
Sony targets retailers with quick sales pitches and rew...
Share and discover new activities with Google Schemer...
Samsung gets 9 mn preorders for Galaxy S3: Report...
Google revamps search engine to think like a person...
 
 Discussion Topics
IT News
Php
Javascript
Technology Updates
Asp.Net
MySql
Ajax
Html
Fedora
Software Testing
Asp
Java
General
Flash
Ruby on Rails