How to add the data present in the controls to a table control without any database involvement.

Hi All,

i am four controls where i will write the text and once i click the add button those should get added to the table .i want 6 columns fixed in the table and rows as many as required.i tried doing that taking a table server control and able to load the table.but the problem is whenver i am adding a new row the old one is gfetting overwritten by this and at the end i am getting only one row. 

System.Web.UI.WebControls.Table t1 = new System.Web.UI.WebControls.Table();

 i have declared the below one global

TableRow tr; TableCell tc1; TableCell tc2; TableCell tc3;

in page load i have written

t1.EnableViewState=true;

Session["Table"]=t1;

 in the add button click i have written

tr = new TableRow();

tc1 = new TableCell();

tc2 = new TableCell();

tc3= new TableCell();

if(Session["Table"].ToString()=="")

{

 

t1.Rows.Add(tr);

 

tc1.Text = "ProjectId";

tc1.BorderWidth=1;

tr.Cells.Add(tc1);

 

 

tc2.Text ="ProjectName";

tc2.BorderWidth=1;

tr.Cells.Add(tc2);

 

tc3.Text= "Name Changed";

tc3.BorderWidth=1;

tr.Cells.Add(tc3);

PlaceHolder1.Controls.Add(t1);

}

else

{

t1=Session["Table"];

tc1.Text="yemo";

tc2.Text="Hello";

tc3.Text="hi";

tr.Cells.Add(tc1);

tr.Cells.Add(tc2);

tr.Cells.Add(tc3);

t1.Rows.Add(tr);

Session["Table"]=t1;

PlaceHolder1.Controls.Add(t1);

but its not working at all.Kindly help me..

 

0
chaitanya_chakkilam
8/23/2007 2:21:26 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies
1274 Views

Similar Articles

[PageSpeed] 12

Hi chaitanya_chakkilam,

 

Based on my understanding, you can use t1 = (Table)Session["Table"]; instead of t1=Session["Table"]; to solve your problem.

Please correct me if I have misunderstood your mean, please LET ME KNOW. Thanks,

Hope it helps,

Hong Gang


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
8/28/2007 1:53:55 PM
Reply:

Similar Artilces:

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

VB access data from Sql database directly without a forms control involved
My Problem is I need to read a table retrieve the information and use it without it being placed into a forms control (I,e  gridview). I am new to asp.met and come from a php backgroound. I can do it the old fashoned way using adodb as before asp.net existed but I believe there must be a new  and better way.   Please Help.     Quick and dirty - very basic: Dim query As String = "Select * From table"Dim connstring As String = "myconnectionstring"Dim conn As New SqlConnection(connstring)Dim cmd As New SqlCommand(query, conn)conn.Op...

Add .Net Control to Web Custom Control
 I want to add .NET Control (like: TextBox, Button...) to Web Custom Control.How i can do it? Alphavn That's called a composite control -- "Mark As Answer" if my reply helped you -- Hello Guys What gunteman said, that is one approach and in most cases the right one.But its also possible to add child controls to a Control thats inherit from WebControl itself. Be sure to implement INamingContainer to that inherited Control too, thats the important point of that approach.--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbuch...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

After a user has entered his registration info I want to add him to my database. Is there a specific control which can handle the update/insert of data from a form into a database?
After a user has entered his registration info I want to add him to my database and also validate whether his name/e-mail is already registered. Is there a specific control which can handle the update/insert of data from a form into a database?If not, how can I add someone? Basically what im asking is how can I add a new user using the best method (best functionality) of the .NET framework. So validate duplicates AND add this user. ;)please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already. Hi, you could use this sample as a...

Bind Data to an Image Control not in a Data Presentation Control
I've been searching for two days but I don't really know what to search for.I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName.  The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

Data presentation without a data control
The Gridview and Formview controls provide good functionality in some circumstances but are clumsey in others. As a newbie to .NET I was wondering if its appropriate to do databinding with textboxes and other data controls outside of one of the new data controls (formview, gridview, etc). Or is it a new standard to always use one of the new data controls. If the answer is yes, would you still use an SQLDatasource, or would you set up the connection in code? And, how would you deal with the syntax? In the Formview we have: <asp:TextBox ID="fnameTextBox" runat="server" ...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

How to use data controls to bind web interface forms to database
 In VS.NET 2002/3, we1. Design Web forms for a user interface2. Create Data connection, Data adapter and dataset.3. Write codes to bind web controls to dataset at runtime.In VS 2005, we have a lot of web data controls, e.g. GridView, to display the database or dataset.  How do we use these data controls to bind the web interface forms to the database or dataset?TIAJeffrey    helo...., in visual studio 2005 is easy to display or bind data from/to database... u can use sqldatasource to take data from database and display in gridview/datalist/repeater/formview. and u can...

Dynamic Slave Controls
I am working a solution to enhance slave controls. I have created a proof of concept based on the 2.04 code base that shows how to load slave controls without switching to the admin view. I have included a sample module that contains 3 view controls. Each control has a row of buttons that can be used to load one of the other 2 controls. (and no I am not using panels.) The default control has a drop down of other instances of the dynamic control that exist on the current tab. Using the module communicator you can raise an event from one control that tells another instance of the module what c...

Convert a html table control to a Table Web Server Control
How Convert a html table control to a Table Web Server Control? add runat="server" attribute to the <table> tag...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

Web resources about - How to add the data present in the controls to a table control without any database involvement. - asp.net.web-forms

Opposition to United States involvement in the Vietnam War - Wikipedia, the free encyclopedia
Protests against the Vietnam War in Washington, D.C., on October 21, 1967 The movement against the involvement of the United States in the Vietnam ...

CPO Erin Egan ‘Strongly’ Denies Facebook’s Involvement In NSA’s Prism Initiative
Facebook Chief Privacy Officer Erin Egan addressed questions about the social network’s involvement in the National Security Agency’s Prism initiative ...

Dr. Ben Carson's Accomplishments, Awards, Honors, and Community Involvement
This is a partial compilation of Dr. Carson's achievements. Learn more from his Curriculum Vitae Retired in June 2013 at Johns Hopkins Hospital ...

Saudi's involvement in 9/11 - LIVE with Senator Bob Graham - YouTube
On 19 December we hosted a live interview with Bob Graham, a former US senator from Florida and the co-chair of the Congressional Joint Inquiry ...

Libya prime minister denies UAE military involvement in his country
... of the UAE and Egypt in military action taken in his country two weeks ago. “We unequivocally deny that the UAE and Egypt had any involvement ...

Accused killer denies involvement
Jesse Willis appeared nervous, claimed he knew "nothing" during initial interview.

Joe Hockey defamation case: Fairfax Media calls for documents regarding Treasurer's involvement in North ...
Fairfax Media has called on a Sydney Liberal Party fundraising forum to provide all documents regarding any involvement by federal Treasurer ...

Premier Denis Napthine had 'direct involvement' in Midfield Meat expansion
Premier Denis Napthine had a ''direct involvement'' in helping pave the way for the expansion of the food processing operation led by wealthy ...

Google flatly denies involvement in PRISM snooping program - National Security Agency, government, industry ...
Google CEO Larry Page strongly denied on Friday that Google allowed the U.S. government back door access to its data centers via a controversial ...

Tony Abbott rules out Australian involvement in Syria campaign if he is PM
TONY Abbott has ruled out intervening in the Syrian conflict if he is elected prime minister, saying Australia should not over-estimate its importance ...

Resources last updated: 12/17/2015 8:53:19 PM