C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




programmatically add controls to a table row


Posted Date: 18 Jun 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: TanujaMember Level: Gold    
Rating: Points: 7



Code in aspx:

<table id="table1" runat="server" style="position:absolute; left: 449px; top: 96px; z-index: 102;">
<tr runat="server" id="trow1">
<td id="tdata1" runat="server">
<asp:TextBox ID="txtbox1" runat ="server" />
</td>
<td>
<asp:DropDownList ID="ddlist1" runat="server" />
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 104;
left: 464px; position: absolute; top: 278px" Text="Button" />

Code in .cs file:

protected void Page_Load(object sender, EventArgs e)
{
TextBox txt = new TextBox();
DropDownList ddl = new DropDownList();
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell =new HtmlTableCell();

cell.Controls.Add(txt);
txt.ID = "txtbox2";
cell.Controls.Add(ddl);
ddl.ID = "dropdown1";
ddl.Items.Add("abcd");
ddl.Items.Add("efgh");
row.Cells.Add(cell);

table1.Rows.Add(row);
}

protected void Button1_Click(object sender, EventArgs e)
{
string str = ((TextBox)table1.Rows[1].Cells[0].FindControl("txtbox2")).Text;
string str1 = ((DropDownList)table1.Rows[1].Cells[0].FindControl("dropdown1")).SelectedValue;
Response.Write(str + " " + str1);
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to bind Radio Button List throuh Sql Server
Previous Resource: How To Adapt A Master Page while Designing .aspx Pages
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use