This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / How to dynamic add some controls in .NET using C#?I tried using placeholder. The controls did dynamic added.However, it added side by side. I want to display them one under another. How can I do it? Anyone know?Thanks in advance.
-graceye88(叶子);
2006-4-27
{179}
(#2932253@0)
-
使用PlaceHolder 和 Panel都行, Panel1.Controls.Add(new Label());想控制位置首先声明一下Label
Label lb1 = new Label();
lb1.Text="this is my lable";
lb1.Style = ...... ;
Panel1.Controls.Add(lb1);
-binghongcha76(一只大猫);
2006-4-27
{138}
(#2932316@0)
-
Thanks! I used PlaceHolder combined with Tablerow and TableCell so I can add controls in the way I like to display.
-graceye88(叶子);
2006-4-28
(#2934088@0)
-
这是我的一段C#程序,供你参考。
-alittleman(凡人);
2006-4-28
{685}
(#2934736@0)
-
Thanks! By the way, how can i trigger an event on a dynamic generated control or get a value from it.
-graceye88(叶子);
2006-4-28
(#2934886@0)
-
there is a set of link buttons on my program, their click event is ..private void lbtPage_Click(object sender, ystem.Web.UI.WebControls.CommandEventArgs e){}
-alittleman(凡人);
2006-4-28
{88}
(#2935476@0)
-
I had a piece of code using similar techonolgy, but it doesn't work. Instead of the linkbutton, i created dropdownlist dynamicly. Can you help me to take a look why my code doesn't work.
-graceye88(叶子);
2006-5-2
{2394}
(#2942297@0)
-
建议你先读一读有关书籍或相关网站,你的问题是比较普遍的. 我猜是ViewState的问题. 处理不好的话dynamic controls的viewstate可能在postback后就丢了.一个方法检查,就是在IE里view source,看有没有你的__doPostBack function.建议你多Google. 比在这里问问题快得多. :-)
-leoxxll(leoxxll);
2006-5-2
{41}
(#2942456@0)
-
Sorry for later reply. you should call the dynamic function in both page load and post back.
-alittleman(凡人);
2006-5-2
(#2942849@0)
-
Thanks!. Yes, I did that, it works fine now.
-graceye88(叶子);
2006-5-2
(#2942926@0)