Click here to Skip to main content
15,911,132 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to generate events for dynamically added controls Pin
Abhijit Jana20-Mar-09 1:47
professionalAbhijit Jana20-Mar-09 1:47 
AnswerRe: How to generate events for dynamically added controls Pin
jaypatel51220-Mar-09 19:06
jaypatel51220-Mar-09 19:06 
QuestionAjax Autocomplete problem in asp.net Pin
gopinathtamil20-Mar-09 1:17
gopinathtamil20-Mar-09 1:17 
Questionhow to use windows user control in web page? [modified] Pin
Member 437854620-Mar-09 1:01
Member 437854620-Mar-09 1:01 
QuestionHow to display in html textboxes Pin
sudheera p20-Mar-09 0:55
sudheera p20-Mar-09 0:55 
AnswerRe: How to display in html textboxes Pin
Michael Bookatz20-Mar-09 1:14
Michael Bookatz20-Mar-09 1:14 
AnswerRe: How to display in html textboxes Pin
Abhijit Jana20-Mar-09 1:42
professionalAbhijit Jana20-Mar-09 1:42 
QuestionDynamic Controls problem, need some help Pin
alex_p0pa20-Mar-09 0:51
alex_p0pa20-Mar-09 0:51 
Hello, this is my first post about such things and the reason for this is that i have to make some webparts in asp and i've tried everything but i can't make it work. What i need is a webpart that has a listbox with items generated after i get some info from another application and based on the selected index in the listbox a number of texboxes are generated. I then need to get the values from the texboxes after i click on a button. From what i've read on the internet I have to recreate the same tree of controls on every postback before viewstate loads so i called my control creation method in the OnInit event. The problem is that at that moment i can't retrieve the selected index of the listbox in order to know which and how many textboxes to create. I tried to store the selected index in session but the selected index changed event of the listbox fires up after the OnInit method so I always get the selected index in the previous case. I find very odd that the listbox does not remember its selected index on each postback and that I have to store it in Session because the viewstate loading event occurs after the OnInit one and from what I know it's best to recreate the dynamic controls in the OnInit method. So basically the information I need to create something is available only after that "something" needs to be created. I'm obviously looking at all of these wrong but it's my first asp .net project so...

This is some of the code, please advise:

protected override void OnInit(EventArgs e)
{
   if (this.Page.Session["index"] != null)
      ListBox1.SelectedIndex = (int)this.Page.Session["index"];
   makeCtrls(ListBox1.SelectedIndex + 1);
   base.OnInit(e);
}

public void makeCtrls(int n)
{
   tbList.Clear();
   for (int i = 0; i < n; i++)
   {
      TextBox t = new TextBox();
      t.ID = n.ToString() + i.ToString();
      t.EnableViewState = true;
      this.Controls.Add(t);
      tbList.Add(t);
   }
}

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
   makeCtrls(ListBox1.SelectedIndex + 1);
   this.Page.Session["index"] = ListBox1.SelectedIndex;
}

QuestionHow to Remove Dot(.) in Url Pin
MallikarjunaGupta20-Mar-09 0:02
MallikarjunaGupta20-Mar-09 0:02 
AnswerRe: How to Remove Dot(.) in Url Pin
Fayu20-Mar-09 9:35
Fayu20-Mar-09 9:35 
QuestionCustome HTTP Handlers and Handler Instance Specifics Pin
Brady Kelly19-Mar-09 23:27
Brady Kelly19-Mar-09 23:27 
Questionuse db(sql server2000) for storing images Pin
Subin Alex19-Mar-09 23:21
Subin Alex19-Mar-09 23:21 
AnswerRe: use db(sql server2000) for storing images Pin
Christian Graus19-Mar-09 23:44
protectorChristian Graus19-Mar-09 23:44 
AnswerRe: use db(sql server2000) for storing images Pin
rajmca.g20-Mar-09 0:52
rajmca.g20-Mar-09 0:52 
AnswerRe: use db(sql server2000) for storing images Pin
Abhijit Jana20-Mar-09 1:39
professionalAbhijit Jana20-Mar-09 1:39 
Questionasp:menu Samples Pin
Brendan Vogt19-Mar-09 22:50
Brendan Vogt19-Mar-09 22:50 
AnswerRe: asp:menu Samples Pin
tech60320-Mar-09 17:10
tech60320-Mar-09 17:10 
GeneralRe: asp:menu Samples Pin
Brendan Vogt20-Mar-09 20:01
Brendan Vogt20-Mar-09 20:01 
Questionvalidation summary in modalpopup extender Pin
sandhya1419-Mar-09 22:40
sandhya1419-Mar-09 22:40 
QuestionEditing item in GridView----Problem ------PLEASE HELP Pin
Member 322226419-Mar-09 22:35
Member 322226419-Mar-09 22:35 
AnswerRe: Editing item in GridView----Problem ------PLEASE HELP Pin
Herman<T>.Instance19-Mar-09 23:11
Herman<T>.Instance19-Mar-09 23:11 
GeneralRe: Editing item in GridView----Problem ------PLEASE HELP Pin
Member 322226420-Mar-09 2:11
Member 322226420-Mar-09 2:11 
GeneralRe: Editing item in GridView----Problem ------PLEASE HELP Pin
Herman<T>.Instance20-Mar-09 3:52
Herman<T>.Instance20-Mar-09 3:52 
AnswerRe: Editing item in GridView----Problem ------PLEASE HELP Pin
Christian Graus19-Mar-09 23:11
protectorChristian Graus19-Mar-09 23:11 
QuestionDatalist Pin
indian2219-Mar-09 22:18
indian2219-Mar-09 22: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.