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 !




dynamically generate some controls in the table’s td tags


Posted Date: 09 Oct 2007    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: rameshgoudd       Member Level: Gold
Rating:     Points: 10



Recently i got this problem and i solved like this
This is for dynamically generating the some controls in the tables td tags
The requirement is
i have a table. and in that i have two rows(trs)
in first row i have two tds .In first td i have a textbox and in second td i have a button named "save"
In second row (tr) i have only one td ........this td consists of a button named "add new row"

if i click on the "add new row " button another row has to be generated dynamically with textbox and button like first row.





<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Dynamically_Generate_Row.aspx.cs"
Inherits="Dynamically_Generate_Row" %>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Page





<% for (int i=0; i<_nRowCount; i++) {%>



<% } %>





















//File:Dynamically_Generate_Row.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Dynamically_Generate_Row : System.Web.UI.Page
{
public int _nRowCount=1;
protected void Page_Load(object sender, EventArgs e)
{
if (null == Session["row_count"])
Session["row_count"] = "1";

_nRowCount = System.Convert.ToInt32(Session["row_count"]);
}

protected void OnCreateRow(object sender, EventArgs e)
{
if (null == Session["row_count"])
Session["row_count"] = "1";
else
{
int i = (System.Convert.ToInt32(Session["row_count"]) + 1);
Session["row_count"] = i.ToString();
}

_nRowCount = System.Convert.ToInt32(Session["row_count"]);
}
}






for more details see my blogs
http://www.beklo.com/rameshgoudd
http://aspspider.wordpress.com




Responses

Author: sweetychinnu    04 Feb 2008Member Level: Gold   Points : 0
NICE ONE...


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: Reading Excel Sheet
Previous Resource: Give Rating
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

online optimum rewards

Contact Us    Privacy Policy    Terms Of Use