Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
well, the title says it all,
and i am not a hero with webbased development

i got an dictionary thats been filled at the page_load :
C#
protected void Page_Load(object sender, EventArgs e)
{
    Dictionary<int, string> values = new Dictionary<int, string>();
    values.Add(0, "Value1");
    values.Add(1, "Value2");
    
    //crebotbox is a dropdownbox
    Crebotbox.DataSource = values;
    Crebotbox.DataTextField = "Value";
    Crebotbox.DataValueField = "Key";
    Crebotbox.DataBind();

}

and its suposed value must pass with the string query through the next page
C#
protected void submitbtn_Click(object sender, EventArgs e)
{
    Response.Redirect(string.Format("~/testpage.aspx?curnmr={0}&crb={1}", Curnmrtbox.Text, Crebotbox.SelectedItem.Value));
}


but no matter wich value i select on the page itself, it just keeps pushing the first value of the dropbox

i have tried switching the Autopostback atribute but that was fruitless.

does someone have an idea?
Posted

1 solution

Corrected your code....

C#
protected void Page_Load(object sender, EventArgs e)
{
    Dictionary<int,> values = new Dictionary<int,>();
    values.Add(0, "Value1");
    values.Add(1, "Value2");
    
    //crebotbox is a dropdownbox
    if(!Page.IsPostback)
    {
    Crebotbox.DataSource = values;
    Crebotbox.DataTextField = "Value";
    Crebotbox.DataValueField = "Key";
    Crebotbox.DataBind();

    } 
}
 
Share this answer
 
Comments
JeroenZonneveld 5-Jul-12 3:16am    
thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900