C#.Net dynamiske knapper og paneler i C#
hej er ved at lave en siden med fler dynamiske knap indput ..men kan ikke hente værdier fra de specifikke
Textboxe det er sammen hold med en edit knap.
hvordan får jeg fat på textboxn.
Panel newpanel;
TextBox textbox;
Button btnEdit;
Button btnDel;
DropDownList dropList;
Literal literal;
int Counter = 0;
foreach (DataRow forum in dt.Rows)
{
newpanel = new Panel();
newpanel.ID = "pnl_" + Counter;
pnlBoards.Controls.Add(newpanel);
literal = new Literal();
literal.ID = "Lit_" + Counter;
newpanel.Controls.Add(literal);
literal.Text = "<div class=\"Boards\">\n" +
"<table class=\"tableHead\"><tr><td>" + forum["fldForumName"] +
"</td></tr>\n<tr><td></td></tr></table>" +
"<div class=\"Indicator\" style=\"background-color:pink; \"></div>\n" +
"<div class=\"Boardsettings\">";
textbox = new TextBox();
textbox.ID = "txt_" + forum["fldID"].ToString();
newpanel.Controls.Add(textbox);
textbox.Text = forum["fldForumName"].ToString();
btnEdit = new Button();
btnEdit.ID = "btnEdit_" + Counter;
btnEdit.Text = "EDIT";
btnEdit.CssClass = "Button";
btnEdit.CommandArgument = forum["fldID"].ToString();
//btnEdit.Attributes.Add("rel", forum["fldID"].ToString());
btnEdit.Click += new System.EventHandler(btn_Click);
newpanel.Controls.Add(btnEdit);
btnDel = new Button();
btnDel.ID = "btnDel_" + Counter;
btnDel.Text = "DEL";
newpanel.Controls.Add(btnDel);
dropList = new DropDownList();
dropList.ID = "ddl_" + Counter;
newpanel.Controls.Add(dropList);
literal = new Literal();
newpanel.Controls.Add(literal);
literal.ID = "litS_" + Counter;
literal.Text = "</div>\n" +
"</div>\n";
Counter++;
}
private void btn_Click(object sender, EventArgs e)
{
ContentPlaceHolder page = Page.Master.FindControl("Content") as ContentPlaceHolder;
Button clickedButton = (Button)sender;
lblTest.Text += clickedButton.CommandArgument;
}