Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem in Setting SelectedValue for DropdownList in Form

Reply
Thread Tools

Problem in Setting SelectedValue for DropdownList in Form

 
 
Charleees
Guest
Posts: n/a
 
      12-30-2005
Hi all,
I have a Problem in Setting the Dropdown selected value.

I have a Page where i get the input for the number of rows and columns
and generate a dynamic table on another page ie) table page.
If i select edit button in table page , the page is redirected to Input
page .
In the input page i have a panel where i have 6 dropdown, which
indicates the Colspan and Rowspan Cordinates and number of Rows and Col
Spaans.
The problem is when i click the edit button, i have to set the selected
value of these dropdowns to some values ie) the table properties .
If the tables row is 3 and Column is 4 , i have to set the row_ddl to 3
and also column_ddl to 4.

I assidn the selected value for these dropdowns as

ddl.selectedvalue = "value"

when i debug , i was getting the right values in the line , but thses
changes are not reflected in the Form.
I am filling the Ddl in Pageload and only if !(page.Ispostback).

Can any one help me please..........

Thanks in advance

 
Reply With Quote
 
 
 
 
Phillip Williams
Guest
Posts: n/a
 
      12-30-2005
Whatever changes to the dropdownlist that you did during the Page_Load will
be lost if the dropdownlist is databound to a datasource. You should set the
selected value of the dropdownlist during the DataBound event.

void column_dll_DataBound(object sender, EventArgs e)
{
//set here the selectedvalue
ListItem li = ((DropDownList)sender).Items.FindByValue("4");
if (li != null) //item was found that has the selected value
{
((DropDownList)sender).ClearSelection(); //clear the old
selection first
li.Selected = true; //set the new selection
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Charleees" wrote:

> Hi all,
> I have a Problem in Setting the Dropdown selected value.
>
> I have a Page where i get the input for the number of rows and columns
> and generate a dynamic table on another page ie) table page.
> If i select edit button in table page , the page is redirected to Input
> page .
> In the input page i have a panel where i have 6 dropdown, which
> indicates the Colspan and Rowspan Cordinates and number of Rows and Col
> Spaans.
> The problem is when i click the edit button, i have to set the selected
> value of these dropdowns to some values ie) the table properties .
> If the tables row is 3 and Column is 4 , i have to set the row_ddl to 3
> and also column_ddl to 4.
>
> I assidn the selected value for these dropdowns as
>
> ddl.selectedvalue = "value"
>
> when i debug , i was getting the right values in the line , but thses
> changes are not reflected in the Form.
> I am filling the Ddl in Pageload and only if !(page.Ispostback).
>
> Can any one help me please..........
>
> Thanks in advance
>
>

 
Reply With Quote
 
 
 
 
Charleees
Guest
Posts: n/a
 
      12-30-2005
hi

i dont have to do anything like databound
i have just 10 values in my dropdown and i have to set according to the
variables values i assign

if i tell 2 then the selected value should be to 1

if i do this i could not set the value i selected

i get some defaults

what should i do

when i assign i get right values ( i checked in debug mode)

please help

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting DropDownList SelectedValue David C ASP .Net 9 11-21-2007 08:05 PM
Data Binding Problem in DropDownList Control SelectedValue to Table text field Tom Jorgenson ASP .Net 3 03-09-2007 10:42 AM
problem about combination gridview-dropdownlist (and selectedvalue) Ben ASP .Net 0 08-15-2006 04:22 PM
Problem with changing the index of the SelectedValue of a DropDownList Thomas Kern ASP .Net 1 11-09-2004 09:47 AM
Setting the SelectedValue of a DropDownList in a Datagrid K Bryan ASP .Net Web Controls 0 04-14-2004 09:23 PM



Advertisments