Click here to Skip to main content
15,905,967 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Deployment errors in asp.net Pin
seee sharp25-Aug-06 1:42
seee sharp25-Aug-06 1:42 
QuestionDatagrid paging........ Pin
Nagraj Naik25-Aug-06 0:19
Nagraj Naik25-Aug-06 0:19 
AnswerRe: Datagrid paging........ [modified] Pin
Suresh Pirsquare25-Aug-06 0:33
Suresh Pirsquare25-Aug-06 0:33 
GeneralRe: Datagrid paging........ Pin
Nagraj Naik25-Aug-06 0:42
Nagraj Naik25-Aug-06 0:42 
QuestionE-Commerce Site Pin
tmoney10125-Aug-06 0:12
tmoney10125-Aug-06 0:12 
AnswerRe: E-Commerce Site Pin
minhpc_bk25-Aug-06 13:28
minhpc_bk25-Aug-06 13:28 
QuestionE-Commerce Site Pin
tmoney10125-Aug-06 0:12
tmoney10125-Aug-06 0:12 
QuestionEventHandler not added when TreeView is created programmatically within if (!IsPostBack) Pin
tengstedt24-Aug-06 23:38
tengstedt24-Aug-06 23:38 
Hi,

I am trying to create a TreeView programmatically, but cannot get my EventHandler to work - unless I do like below - is that really the way to do it?

I want to add a TreeView and when the user posts back some data, I want that data in the TreeView. My first thought was to put in if (!IsPostBack) before the CreateTreeView() call and then add the data in the EventHandler and then calling the CreateTreeView() at the very end. This, however, does not add the EventHandler Frown | :(

Do you really have to create the control twice? Once with the pre postback data and then one after adding the postback data to the control. The example below is very simple, but in my real app it will cause a lot of trouble as there are many controls with EventHandlers being added.

Can you execute any code after the events have fired?

I have been looking high and low for an answer, but have found none, so I hope some one can help Smile | :)
If you need more info, please let me know.

Kind regards,
Lars

public partial class _Default : System.Web.UI.Page
{
StringCollection nodes = new StringCollection();
TreeView TreeView1 = new TreeView();

protected void Page_Load(object sender, EventArgs e)
{
TreeView1.SelectedNodeChanged += new EventHandler(NodeChanged);
nodes.Add("Node1");

//if (!IsPostBack)
CreateTreeView();
}
protected void NodeChanged(object sender, EventArgs e)
{
// This could be data added by the user
nodes.Add("Node2");
CreateTreeView();
}

void CreateTreeView()
{
TreeView1.Nodes.Clear();
foreach (string s in nodes)
{
TreeNode node = new TreeNode(s);
TreeView1.Nodes.Add(node);
}

this.form1.Controls.Add(TreeView1);
}
}

AnswerRe: EventHandler not added when TreeView is created programmatically within if (!IsPostBack) Pin
Mircea Grelus24-Aug-06 23:54
Mircea Grelus24-Aug-06 23:54 
GeneralRe: EventHandler not added when TreeView is created programmatically within if (!IsPostBack) Pin
tengstedt25-Aug-06 0:28
tengstedt25-Aug-06 0:28 
QuestionData type of functions Pin
Kartik Rathi24-Aug-06 23:17
Kartik Rathi24-Aug-06 23:17 
AnswerRe: Data type of functions Pin
Paddy Boyd24-Aug-06 23:24
Paddy Boyd24-Aug-06 23:24 
GeneralRe: Data type of functions Pin
_AK_24-Aug-06 23:29
_AK_24-Aug-06 23:29 
AnswerRe: Data type of functions Pin
Mircea Grelus24-Aug-06 23:27
Mircea Grelus24-Aug-06 23:27 
GeneralRe: Data type of functions Pin
_AK_24-Aug-06 23:29
_AK_24-Aug-06 23:29 
QuestionWhy Different browsers showing different size of asp.net controls? Pin
thomas_joyee24-Aug-06 23:14
thomas_joyee24-Aug-06 23:14 
AnswerRe: Why Different browsers showing different size of asp.net controls? Pin
Mircea Grelus24-Aug-06 23:36
Mircea Grelus24-Aug-06 23:36 
GeneralRe: Why Different browsers showing different size of asp.net controls? Pin
thomas_joyee24-Aug-06 23:50
thomas_joyee24-Aug-06 23:50 
GeneralRe: Why Different browsers showing different size of asp.net controls? Pin
_AK_25-Aug-06 0:00
_AK_25-Aug-06 0:00 
QuestionHow to support different different date formats in web application Pin
Software_Guy_12324-Aug-06 23:04
Software_Guy_12324-Aug-06 23:04 
AnswerRe: How to support different different date formats in web application Pin
_AK_24-Aug-06 23:10
_AK_24-Aug-06 23:10 
GeneralRe: How to support different different date formats in web application Pin
Software_Guy_12325-Aug-06 0:42
Software_Guy_12325-Aug-06 0:42 
GeneralRe: How to support different different date formats in web application Pin
_AK_25-Aug-06 0:48
_AK_25-Aug-06 0:48 
GeneralRe: How to support different different date formats in web application Pin
Software_Guy_12325-Aug-06 1:10
Software_Guy_12325-Aug-06 1:10 
GeneralRe: How to support different different date formats in web application Pin
_AK_25-Aug-06 1:18
_AK_25-Aug-06 1:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.