Click here to Skip to main content
16,004,778 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: sliding or collapsible display Pin
Sandeep Mewara10-Aug-10 22:27
mveSandeep Mewara10-Aug-10 22:27 
GeneralRe: sliding or collapsible display Pin
Vinay Varghese12-Aug-10 13:06
Vinay Varghese12-Aug-10 13:06 
QuestionSiteMapPath: Don’t show the root level in breadcrumb Pin
anderslundsgard10-Aug-10 19:30
anderslundsgard10-Aug-10 19:30 
AnswerRe: SiteMapPath: Don’t show the root level in breadcrumb Pin
Prosanta Kundu online10-Aug-10 20:48
Prosanta Kundu online10-Aug-10 20:48 
GeneralRe: SiteMapPath: Don’t show the root level in breadcrumb Pin
anderslundsgard11-Aug-10 18:51
anderslundsgard11-Aug-10 18:51 
Questionsome IEEE projects in ASP.NET Pin
ram_kesari10-Aug-10 17:28
ram_kesari10-Aug-10 17:28 
AnswerRe: some IEEE projects in ASP.NET Pin
Prosanta Kundu online10-Aug-10 18:13
Prosanta Kundu online10-Aug-10 18:13 
Question(DropDownList.DataSource == null) after postback Pin
Łukasz Nowakowski10-Aug-10 4:53
Łukasz Nowakowski10-Aug-10 4:53 
First I must say, that I'm rather a beginner with ASP.NET, so my question might be stupid. If it is, please spend some time to explain me why it's like this Wink | ;-)
Let's say I have a DropDownList bound to a collection of items of some type. For example this type:
public class Country
{
    public int Id
    {
        get;
        set;
    }

    public string Code
    {
        get;
        set;
    }

    public string Name
    {
        get;
        set;
    }
}

On the aspx page I place a DropDownList like this (button is only for triggering postbacks):
<asp:DropDownList runat="server" ID="test" DataTextField="Name" DataValueField="Code" /><br />
<asp:Button runat="server" ID="temp" Text="Postback" />


And in the code-behind for aspx I write:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    if (!IsPostBack)
    {
        test.DataSource = WebApplication2.Controls.CountriesDropDown.CountriesList();
        DataBind();
    }
}

(WebApplication2.Controls.CountriesDropDown.CountriesList() returns a Collection<country> instance)
And now, when I hit the postback button, on the server side I see the DataSource is null. However in the browser I can still see the countries displayed earlier.
Is there any way to have access to objects being bound, cause I don't want to generate the list again.

I didn't turn off ViewState (I found this suggestion when searching for solution)
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

AnswerRe: (DropDownList.DataSource == null) after postback Pin
Sandeep Mewara10-Aug-10 6:05
mveSandeep Mewara10-Aug-10 6:05 
GeneralRe: (DropDownList.DataSource == null) after postback Pin
Łukasz Nowakowski10-Aug-10 8:10
Łukasz Nowakowski10-Aug-10 8:10 
QuestionExcel Error :( Pin
Mugdha_Aditya10-Aug-10 3:12
Mugdha_Aditya10-Aug-10 3:12 
GeneralRe: Excel Error :( Pin
Paladin200010-Aug-10 3:51
Paladin200010-Aug-10 3:51 
AnswerRe: Excel Error :( Pin
Prosanta Kundu online10-Aug-10 18:07
Prosanta Kundu online10-Aug-10 18:07 
QuestionMore than one programmer working on the EF4 model file Pin
Brendan Vogt10-Aug-10 2:48
Brendan Vogt10-Aug-10 2:48 
QuestionReplace ImagePlaceHolder1 in Word 2007 with the image selected in Combo box in C#.net Windows Application Pin
raghvendrapanda10-Aug-10 0:02
raghvendrapanda10-Aug-10 0:02 
AnswerRe: Replace ImagePlaceHolder1 in Word 2007 with the image selected in Combo box in C#.net Windows Application Pin
Prosanta Kundu online10-Aug-10 18:02
Prosanta Kundu online10-Aug-10 18:02 
GeneralRe: Replace ImagePlaceHolder1 in Word 2007 with the image selected in Combo box in C#.net Windows Application Pin
raghvendrapanda10-Aug-10 22:42
raghvendrapanda10-Aug-10 22:42 
Questionhex string to sql and to website Pin
meenu s9-Aug-10 12:32
meenu s9-Aug-10 12:32 
QuestionQuestion about saving an image to SQL database Pin
Aptiva Dave9-Aug-10 10:09
Aptiva Dave9-Aug-10 10:09 
AnswerRe: Question about saving an image to SQL database Pin
NeverHeardOfMe9-Aug-10 10:32
NeverHeardOfMe9-Aug-10 10:32 
GeneralRe: Question about saving an image to SQL database Pin
InderK10-Aug-10 1:29
InderK10-Aug-10 1:29 
QuestionThread from code behind aspx Pin
devvvy9-Aug-10 2:34
devvvy9-Aug-10 2:34 
AnswerRe: Thread from code behind aspx Pin
Prosanta Kundu online9-Aug-10 2:52
Prosanta Kundu online9-Aug-10 2:52 
AnswerRe: Thread from code behind aspx Pin
NeverHeardOfMe9-Aug-10 3:27
NeverHeardOfMe9-Aug-10 3:27 
QuestionNeed example code for making an universal table editor... Pin
Hrizip8-Aug-10 21:14
Hrizip8-Aug-10 21:14 

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.