rss

Load data into controls in asp.net

by on Jul.13, 2010, under C Sharp, Development, Web

Usually when working on windows form, I use this to do the work

        DropDownList1.DataSource = new ApplicationTableAdapter().GetDataBySystemID(1);
        DropDownList1.DataTextField = "Name";
        DropDownList1.DataValueField = "ID";

But surprisingly, when switched to ASP.NET, the above code no longer works, at first I thought it was a problem with the paradigm so I tried to store the data as a session variable but that didn’t work either, until I tried this

        DropDownList1.DataSource = new ApplicationTableAdapter().GetDataBySystemID(1);
        DropDownList1.DataTextField = "Name";
        DropDownList1.DataValueField = "ID";
        DropDownList1.DataBind();

One extra line.

:, , , ,
No comments for this entry yet...

Leave a Reply

preg_match() in action

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post to let me know! :)