Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Alright, I need to create a table (did it) that will have rows and cells (duh), and I need it to have a button in one cell that says add(did it).. this is all in an asp:table . When the button is clicked (having trouble referencing it since it is in the table, some reason VS won't recognize it, so I must be doing something wrong.. and I can't double click it to get it to recognize it itself - clicking on it highlights the entire table) have it add a new row with 7 cells and all the same controls as in the first row.

Then I need to be able to get data from each of those textboxes (3), dropdownlists (1), radiobuttonlists (2), and a button that says add or I can reference the add button before or something... so I can add the data to a database.

 

Problem is, I don't know how to do it.

Oh - i am using C#.

searched web 100 times... nothing to do exactly what I need it to... or for the most part, anything close. Searched here... couldn't find my solution either...

ANY help is greatly appreciated.

Amy

Posted

A table cell is a naming container; to wire an event you need to manually make the event with the proper delegate in your code behind - it won't automagically wire up for you because the control is not a part of the Form control collection, it's is a part of the Cell control collection which is a part of the Row control collection which is a part of the Table control collection - only events of the table control itself could be wired up in the desiger - you need to have code like the following:

 

protected void tableButton1_OnClick(object sender, EventArgs e)
{
    //code
}

 

Or if you prefer VB:

 

Protected Sub tableButton1_OnClick(ByVal sender As Object, ByVal e As EventArgs)
     'Code
End Sub

 

Then in the html code your button would have:

 

<asp:Button id="tableButton1" runat="server" OnClick="tableButton1_OnClick"></asp:Button>

 

There are of coarse otherways to do it, but this, in my opinion, is the easiest to trace and understand.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...