adding / deleting table rows, and accessing controls within added rows

Hi everyone,

I would like to know what is a good and simple way to achieve this using asp.net. 

Basically i would like the ability to add and delete rows, preferably table rows.  Against each row is its delete button, hitting it will delete the corresponding row.  There is only 1 Add button to add a new row. 

In each row, there are say 2 textboxes.  When i hit, say a calculate button, i wish to be able to access all the available textboxes in all the available rows in the event handler, and say just output a sum.

If GridView is suggested, could you please explain why it is used when in this case i have no meaningful datasouce ( i only have user input ) for the GridView.

 

Thanks

0
chickenlaksa
9/2/2008 6:58:45 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
990 Views

Similar Articles

[PageSpeed] 48

 bumpity....no one can help me ? :(

0
chickenlaksa
9/3/2008 12:11:09 AM

 still no one ....? i'm about to give up...

0
chickenlaksa
9/3/2008 7:40:07 AM

Hi chickenlaksa,

I recommand you use the gridview control.

(1)You can add the 'add','delete' ,'modify'button at the bottom of gridview.

When user click 'delete','modify' button, he must select an item form gridvew, then you can operate the related row.

Then you can rebind the gridview.

(2)When user click 'add' button, you can add can make pannel visiual in order to input some value.

But you can use javascript to operate table, and caluate the total sum.

http://www.codeproject.com/KB/HTML/html.aspx

 


Sincerely,
Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hua
9/5/2008 3:25:00 AM
Reply:

Similar Artilces:

Deleting a row and adding it to another table while adding more info to it ?
Hi,So far I have my code displaying parts of a table in my access DB. I would like to add a delete option next to each row it returns. When a user clicks the delete link/button I want it to take them to another page where they can add some more info about why that row is being deleted (like a comment or note) and then have that row moved to another table in the access db. The row should also be removed from the original table as well.Any help is much appreciated. Thanks Hello,Follow this scenarioViewRows.aspx pageu can place a link beside each record with delete caption. The link will redi...

Adding row (one at a time) in gridview on a button click. And cells of added row should contain controls like DROPDOWN LIST or TEXT BOX.
Dear Friends, I am in great need for the solution/hints/guidance of my requirement, if anyone can help with.  Let me explain what I need."I need a Gridview control on a webpage having following 5 columns/fields.     Column 1: It just has a "+" button in its header only (other cells for this column is empty)    Column 2: The Column header here is "FIELD" and  it should contain dropdown list (which is populated from some database)    Column 3: The Column header here is "Operator" and  it should ...

adding rows in Tables control.
Hi, I have a Table control in asp.net now that table has 5 rows and 4 columns and all columns has a textbox.there is a button "Add".I want that when I click on "Add" button in that table one row and 4 columns will be added in that tableI have done but it create only once, but I want suppose that I click on buttons 4 times then there should be 4 more rows to be add.How can I do it???????????? Dynamically you generate the table. Keep some initial value which will be shown for the first time loading for the no of row. Like suppose 4 the the intial page load time you can able to see the 4 rows. Now everytime you are adding the row it should increase 1 to that value and depending on that the tables row will be added. Thanks for yor reply,  I have done it as: public void CreateControls() { // Total number of rows.int rowCnt; // Current row count.int rowCtr; // Total number of cells per row (columns).int cellCtr; // Current cell counterint cellCnt; rowCnt = 5 cellCnt = 4;for (rowCtr = 1; rowCtr <= rowCnt; rowCtr++) { // Create new row and add it to the table.TableRow tRow = new TableRow(); Table1.Rows.Add(tRow);for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++) { // Create a new cell and add it to the row. TableCell tCell = new TableCell();TextBox txt = new TextBox();txt.CssClass = "textbox"; txt.Width = 160; tCell.Controls.Add(txt); tRow.Cells.Add(tCell); } } }   The above function creates 4 rows...

adding a blank header row /row above the header row
is it possible to add a blank row above the header row in gridview for adding some links and buttons the links will respond to thae data in the grid and the buttons are for login / regisration etc....  if yes how it can be done or how do i achieve it. Its better that u create a table with a single row with columns matching the GridView columns. Set the table width same as the GridView width. This will make the GridView Look as if there is a row above its header.Please do not forget to click Mark As Answer on the post that helped you. Regards,Iam Srikanth Reddy....

Adding accessibility controls to a web form
Hey, Just wanted to know if it was possible to create a apsx page which allowed the user to change the size of the applications text size through the whole application (I'm using CSS and themes) and invert colours (background and text)? Would it be possible to assign these controls onto buttons to allow users to change the application?I know I have seen sites with the option to change the text size (usually there is a series of "A"'s going from small to large). But I haven't seen a web page that allows the user to invert the browsers colour scheme. Cheers for ...

Problems adding a row to Access table
Please help. I am having problems adding a row to a table in an access database. I am very new to ASP.NET so I am reading / referencing ASP.NET for Dummies, from what I can tell I have done everything correctly but the page will not add to the table. I am receiving an error within the second Sub Routine Here is the Source Code I am currently using: <script language="VBScript" runat="server"> Dim ConnectString, SelectStatement As String Dim Connect As OleDbConnection = New OleDbConnection Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter Dim NotAnnCB As OleDbCommandBuilder Dim NotAnnDS As DataSet = New DataSet Dim Row As DataRow Dim NotAnnSent As Integer Dim ClassIndex As Integer Dim DepartmentIndex As Integer Sub Submit_Click(Sender As Object, E As EventArgs) NotAnnSent = Request.QueryString("NotAnn") GetNotAnn(0) Row = NotAnnDS.Tables("tblNotificationsAnnouncements").NewRow Row.Item("Date") = Today Row.Item("Class") = ClassDropDown.SelectedItem.Value Row.Item("Department") = DepartmentDropDown.SelectedItem.Value Row.Item("Title") = TitleText.Text Row.Item("Description") = DescriptionText.Text NotAnnDS.Tables("tblNotificationsAnnouncements").Rows.Add(Row) Adapter.Update(NotAnnDS, "tblNotificationsAnnouncements") If NotAnnDS.HasErrors Then MessageError.Text = "There wa...

adding row to a table control on button click
 Hi all, I'm trying to do something rather straightforward, but it's not working.I'm creating some sort of timesheet application where I want to be able to add rows with some date fields to my table control after I click on a button "add new row". This is the code I have behind the button "add row", and it works the first time I click it, but when I click it a second or a third time, no rows are being added... Any idea on how to solve this? Screenshot is here:  1 Protected Sub btnAddRow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddRow.Click 2 ' add a new row to timesheet application 3 intRowCounter += 1 4 5 Dim extrarow As New TableRow 6 7 Dim extracel1 As New TableCell 8 Dim extracel2 As New TableCell 9 Dim extracel3 As New TableCell 10 Dim extracel4 As New TableCell 11 Dim extracel5 As New TableCell 12 Dim extracel6 As New TableCell 13 Dim extracel7 As New TableCell 14 Dim extracel8 As New TableCell 15 16 ' bind new dropdownlist with related tasks to selected study 17 Dim extradropdown As New DropDownList 18 extradropdown.DataSourceID = ObjectDataSourceTasks.ID 19 extradropdown.ID = "ObjectDataSourceTasks" & intRowCounter 20 21 extradropdown.DataTextField = "task_na...

Adding a new row between rows
Hi to all. I'm trying to do a sort of SubReport. At this moment I have This Code made. It verifies if the column is equal it will erase it's text. What I would like to do now is if the Cell is not Equal then it will create a row with a label that says Sub Report. I tried some code but it inserts the row at the end. Can any one help me? protected void gridDefectReport_RowDataBound(object sender, GridViewRowEventArgs e)    {         if (e.Row.RowIndex > 0)        {     &nb...

Adding Dynamic row to Row
I have written the following code in javascript. This code is working fine in FireFox but not in IE 7.Need help so that it should  also work fine in IE7.Thanks.  var repeater= document.getElementById('<%=repeater.ClientID %>');        var obj = result;        var newRow = document.createElement("tr");        var newCell = document.createElement("td");        var ctrlInputHid = document.createElement("input...

Problem accessing Ids of last row after dynamically adding row to GridView
I'm adding a "header" row to a gridview.  In the RowDataBound method I get the table of the gridview (e.Row.Parent), I then create a new row:Dim newRow As New GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal)Add some html to it and then add the row to the table:ParentTable.Rows.Add(newRow)This renders correctly.  However, in the gridview rows, I also have a link button.  For the most part this works, I click on the link button and am able to get the Id from the command argument.Funny thing is that if I click the link button in the last row, my event never fires.  I'm guessing the index of where this happends is > than the number of rows so it never raises the click event on the link button??When I add the row do I need to increment some counter so it knows there is another row?Thank you, - Andy Andy Dynamic rows need to be persisted.  As I understand it, viewstate only handles statically built controls. Dynamic stuff is your resposibility to persist.I am not anti social, am just not user friendly Hi ballistic , ballistic:Funny thing is that if I click the link button in the last row, my event never fires.  I'm guessing the index of where this happends is > than the number of rows so it never raises the click event on the link button?? Here is one workaround. I am using northwind database. When I click the button which reside in the dynamically added row, the event is fired p...

adding columns via alter table deletes rows
I have a very weird situation here. I'm running ASE 12.5.0.3 with EBF10688. For some reason, I'm losing ~100000 rows on a table after running the following command: alter table customer add client_num varchar(12) default "111" not null, cust_society_num varchar(3) default "999" not null The locking schema of this table is datapages. I also lost additional rows using this command on the same table: alter table customer modify external_ref varchar(25) not null However, when I ran a test of the same steps on the same table created with allpa...

Dynamically adding rows / cells to table server control
I'm looping through and adding rows / cells to a table server control.  Works without a problem.  However, when go to perform an operation on that table (after clicking a linkButton) the table goes back to it's original form (ie. only containing a header row).  What am I doing wrong?<asp:Table ID="copySkuTable" runat="server" CssClass="item" >        <asp:TableHeaderRow HorizontalAlign="left" CssClass="item">           ...

Accessing controls created in a dynamic added gridview row
 Hi all,1) On page_load i'm adding a new row at the end of my gridview. Inside the new row i'm creating a new textbox :If Not GridView1.Rows.Count = 0 ThenDim oGridViewRow As New GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Insert)Dim oTableCell As New TableCell()Dim TextBox1 As New TextBoxTextBox1.ID = "TextBox1"oTableCell.Controls.Add(TextBox1)GridView1.Controls(0).Controls.AddAt(GridView1.Rows.Count + 1, oGridViewRow)2) I would like, when I click on button1 (somewhere in my page), to be able to retreive the value of TextBox1.I'm currently un...

Adding rows from a table to another table in a dataset
Hi everybody. How can I copy all the data from a dataset's table to another table. The table I'm copying the data to is going to get all the data from that other table several times, cause the source table's data is going to be changing constantly. And I want to store all the data in that table. Is there a function to do that? Or do I have to copy the data row by row? I mean dataset1.tables("table1").rows.add(dataset2.tables("table2").rows(X)) ' where X is the index Thanks in advance newDataTable = dataset1.Tables("table1").CopyMike Ba...

Adding table rows to a table in an update panel
I'm trying to add table rows to a table that has already been added to the update panel (ie, in design view). When I run my code, the text changes on the page, but I dont get additional rows, its as if its forgetting about the first row that was already added and simply over writing it... Anyone got any thoughts?  I had a label in there before where I'd reference the label and add text to the existing text, that worked fine, the text that was already there just stayed and the dialogue got longer etc, why is it different with the table rows? Any help would be appreciated..Rega...

Adding row to a table
Hi, I am making a table to wich a user can add row to it. He can do this by right clicking on the table, a home-made js contextmenu will appear. If he clicks on the contextmenu: there will be a postback + a message. this is done by this code: NewLine.Attributes.Add("onclick","javascript:HideContextMenu);"+Page.GetPostBackEventReference(this,"Add@@1")+";"); Because it is a postback, all the rows must be reconstruced (also the ones that already were present). The strange thing is that if I reconstruct all the row, I just make new dataRows and somehow he still saves the data I already inputed! I didnt write any code for that! To give an example (the real thing is quite long) when a postback occurs: TableRow row=new TableRow(); TextBox txtJName=new TextBox(); TableCell cel=new TableCell(); cel.VerticalAlign=VerticalAlign.Top; cel.Controls.Add(control); row.Cells.Add(cel); You see, no extra code! But he still knows what I wrote into that textBox when I ask for an extra line. So the question is, how does he know this? Where did he save this? And how can I get to this data? Thx for reading this and helping me with this! Hello, what is happening with you is that, the Viewstate is being enabled so everything found in the server controls are saved within the vewstate and on the postback they are present again. you can disable viewstate EnableViewstate = false set thisin the head of th...

adding rows to a table
I have a tabe to which I want to add a row each time I click a button (See my code below). The problem with this is, it only adds a row when I click the button the first time. The following clicks of the button, does not add rows. Pls help. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer Dim newrow As New TableRow Table1.Rows.Add(newrow) For i = 1 To 5 Dim newcell As New TableCell newcell.Text = i newrow.C...

SM 2.1 : Composer: Table issue adding/deleting rows
Previous versions used to have a small graphic on the table to easily allow you delete row or add row above/below. This is now gone. This was incredibly useful. Sun, 26 Jun 2011 10:38:35 +0100, /Derek Wallace/: > Previous versions used to have a small graphic on the table to > easily allow you delete row or add row above/below. > This is now gone. This was incredibly useful. This is probably related to "V2.1 problem in Composer mode" [1] thread. As far as I know, the SeaMonkey developers have intention to improve the situation in future versions, but unfortun...

Deleting rows from one table based upon rows in another table
I need to delete rows from table1 based on rows in table2. table1 has 1.5 million rows from which I need to delete 20,000 existing in table2. The table structures are the same and I must exactly match 10 (of the 15) columns in the tables. I also need to limit the number of rows being worked on, in a single transaction, to 500 or so. Hi Mike, try the following: set rowcount 500 DELETE table1 from table1 t1,table2 t2 where t1.col1=t2.col1 and t1.col2=t2.col2 and t1.col3=t2.col3 and ........ t1.col10=t2.col10 HTH. Regards P:S You must re-execute the DML statement above 40 time...

Deleted row information cannot be accessed through the row.
I have a DataSet in which I need to make multiple changes prior to saving. Here's the scenario where I'm having the problem:1. I delete a row and it disappears from the table.2. I attempt to add another row.3. I receive an error that "Deleted row information cannot be accessed through the row." when the the screen posts back and refreshes.Here's the code for deleting:<code>protected void dgEmail_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Debug.WriteLine("dgEmail_DeleteCommand"); EnableSaveBtn(); dgEmail.EditItemIndex = -1; dsEmail.Tables["email"].Rows[e.Item.ItemIndex].Delete(); //dsEmail.Tables["email"].AcceptChanges(); dgEmail.DataSource = dsEmail; dgEmail.DataMember = "email"; dgEmail.DataBind(); }</code>If I uncomment the line to AcceptChanges the error no longer occurs but the row is not deleted from the database when I update everything. Try moving 'dgEmail.EditItemIndex = -1;' to where i have it bold and underline in your code and run it again.Let us know if that fixed things.Debug.WriteLine("dgEmail_DeleteCommand"); EnableSaveBtn(); dsEmail.Tables["email"].Rows[e.Item.ItemIndex].Delete(); //dsEmail.Tables["email"].AcceptChanges();dgEmail.EditItemIndex = -1; dgEmail.DataSource = dsEmail; dgEmail.DataMember = "email"; dgEmail.DataBind();DarmarkMark as Answer, if this reply answers your post. No, that didn't fix it. Same error. The row deletes but if I try to add another one (or delete another on...

Deleted row information cannot be accessed through the row.
I'm getting an exception with the message "Deleted row information cannot be accessed through the row". I have processing the records through the data table. In some situation i have deleted the rows in the datatable and inserting the new rows. These situation i have get the above specified error. Regards, Vijay Hi Vijay, this error occours when u try to access the row which u have already deleted. So, try to check if the row exists or not and then retrieve the information. I hope this will help u..Please mark as Answer if it helps u. Thanks!Parth PatelTechsture TechnologiesSoftware DeveloperAhmedabad If you wish to access information on the row that is being deleted, try doing is in the datagrids rowdeleting event. This event fires before the row is deleted from the database.ASBESTOS Greetings Hi, Use Datatable.Acceptchanges() after you have deleted the row and  before you access a row. regards, varun Hi vijay_.net, If the DataRow.Delete method is called, the row transitions such that its RowState is DataRowState.Deleted. (It is only acutally removed from the DataTable when AcceptChanges is called.)When a row is in DataRowState.Deleted, the normal means for accessing the values do not work (as you have seen).  If all you need to know is that the row is deleted, check the RowState property.  If you need to retrieve the "original", deleted data, you can use an overload of he Item property.  For example, if dr...

Add Table Row containing TextBoxes dynamically + Access data from dynamically added TextBoxes
Let's say I have a table, each row containing 5 cells, each cell containing a TextBoxBy default, I want only 1 row showing... but I want to have a Button that allows me to add an additional row every time it's clickedHow do I dynamically add TableRows containing TextBoxes in VB? Or is this something that should be done client-side with Javascript?I also want to be able to use the user's input from these TextBoxes in the body of an email that will be sent through the web page when the user clicks a "Submit" button on the page.I'm new to VBScript so I'm really loo...

How to determine the row number when clicking a delete button I added to a template column from a GridView control???
Hello all,I am working using the codebehinde the page with VB.NET 2005 (web application).  I have a gridview where I added a template column, inside that templated column I added a delete button.  I would like to know how could I determine which row number corresponds to the clicked button so I can delete the current record.This is what I have: Protected Sub LinkButtonDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Try Dim cmd As SqlCommand Dim objConnection As SqlConnection objConnection = New SqlConnecti...

Adding ajax extenders to custom controls added at runtime within a wizard control
Hi guys,  I have a problem where i have a web page (inheriting from a master page which contains the scriptmanager control) containing a dynamically created wizard control. At runtime i add the steps from custom controls i have created, basically simulating content etc. Now - when i try to add ajax extenders to the custom controls it errors out on load and says that the controls havent been registered - have scoured the web but cant seem to find any info re what the cause/solution is - help please. Hi, What exactly the error says? Did you look into your web configuration file (web.config). Did you change anything in there?...

Web resources about - adding / deleting table rows, and accessing controls within added rows - asp.net.web-forms

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: http://facebook.com/AmericanFilmInstitute ...

Accessing the Future Fund a sensible proposal, says super expert Daryl Dixon
As portfolios go, the Future Fund's asset allocation is concentrated in higher-risk investment, including equities and alternative assets.

Accessing my Super
I'm 57 - can I access my super?

Australia, US accessing Indonesian telephone data, leaked documents show
Newly disclosed documents from former US intelligence contractor Edward Snowden have revealed that Australian intelligence efforts against Indonesia ...

Euthanasia advocate Philip Nitschke detained at Melbourne Airport, accuses Customs officials of accessing ...
Euthanasia advocate Philip Nitschke has accused Customs officials of accessing hundreds of patients' sensitive records on his laptop after detaining ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 3/6/2016 10:44:14 AM