Problem to Dropdownlist

Hi,
I have the codes like
 
        sql = LibUtil.GetSqlCodeVG(accessRight, dept);
        dt = DBUtil.GetCodeTable(conn, sql);
        ddlStore.DataSource = dt;
        ddlStore.DataValueField = "code";
        ddlStore.DataTextField = "dscr";
        ddlStore.DataBind();
 
    public static string GetSqlCodeVG(string accessRight, string dept)
    {
        string sql = @"select store_no code, sfzone, concat(ifnull(dscr,''),',  ',ifnull(store_no,'')) as dscr
            from c_store_vg c
            where deleted = '0' and dscr is NOT NULL ";
 
        sql += "order by dscr ";
 
        return sql;
    }
 

Open in new window

to fill the Dropdownlist. But after I've selected one value to the DDL, I check that
 
ddlStore.SelectedValue
 
is having empty value inside. why?
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ChloesDadCommented:
SelectedValue will work, but only if you keep the databinding of the list in !IsPostBack. Otherwise the selected value will reset to the default selected value.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverAuthor Commented:
Can you please show with example codes to your advice? thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.