471,857 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,857 software developers and data experts.

ASP.NET C# Table and Buttons

This is the strangest bug I have ever seen with ASP.NET. I've got a table that is programaticly made using C#. Everything works fine, i get a table with a list of emails from a database, i click edit and all the Labels turn into TextBoxes on that row where i clicked edit.

Expand|Select|Wrap|Line Numbers
  1.                 TableCell cell5 = new TableCell();
  2.                 Button b = new Button();
  3.                 b.Text = "Save";
  4.                 b.Style.Add("Width", "90px");
  5.                 b.CommandArgument = (i + 1).ToString();
  6.                 b.Click += new EventHandler(save_Click);
  7.                 cell5.Controls.Add(b);
  8.                 row.Cells.Add(cell5);
But when I click this save button, it posts back to the server but nothing happens. When i click it again it called save_Click :s

When i click edit it also brings up a few new rows for the alias of the email account i just clicked. When i click delete next to the aliases it sometimes deletes (but i have to click it twice again), sometimes it deletes the wrong one. Sometimes it adds a new one with a username of the disk quote for that email account eg. 6@domain.com

The function that makes the table is in the page_Load() because if i put it anywhere else, it deletes the table every time I post back to the server :s

Anyone came across this before or know how to fix any of these problems?


i read the html source of the table, when i load the page, values of the edit button
[HTML]<input type="submit" name="ctl17" value="Edit" style="Width:43px;" />[/HTML]
and then after i clicked it once...
[HTML]<input type="submit" name="ctl05" value="Edit" style="Width:43px;" />[/HTML]
then when i click that one, it called the edit_Click()
Aug 7 '07 #1
1 8783
Okay i fixed it now -_-
I added

Expand|Select|Wrap|Line Numbers
  1. b.ID = "edit" + i.ToString();
and the server obviously knew which button it was pressing after i gave it an ID :D
Aug 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Werner Partner | last post: by
8 posts views Thread by John Smith Jr. | last post: by
3 posts views Thread by Macbane | last post: by
7 posts views Thread by lawpoop | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.