Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataGrid with Dropdown list

Reply
Thread Tools

DataGrid with Dropdown list

 
 
vijay_kerji@yahoo.com
Guest
Posts: n/a
 
      02-18-2005
Any Help is appreciated!
I have a datagrid with Drop down list and a remove hyperlink as two
columns.
When I remove the row of the datagrid by clicking on the remove
column,Dropdown list is mentaining its previous state.
i.e Removed dropdownlist's selected value is applied to the next
datagrid item's dropdown list.

DATAGRID
---------------------------------------------------------
"Remove" | "<DropDownList1>"
---------------------------------------------------------
"Remove" | "<DropDownList2>""


When the first row is removed, "DropDownList2" becomes
"DropDownList1"!!!

How to solve this problem?

Thanks
Vijay

 
Reply With Quote
 
 
 
 
Samuel Kim
Guest
Posts: n/a
 
      02-19-2005
Can you pls post some of the code you are using?

 
Reply With Quote
 
 
 
 
Samuel Kim
Guest
Posts: n/a
 
      02-19-2005
Can you pls post some of the code you are using?

 
Reply With Quote
 
Vijay Kerji
Guest
Posts: n/a
 
      02-21-2005
"Samuel Kim" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) roups.com>...
> Can you pls post some of the code you are using?


Hi,
The following code is used in the 'remove' hyperlink click handler.

foreach(DataGridItem DemoGridItem in dataGrid_AddUsers.Items)
{
DropDownList myDDList =
(DropDownList)DemoGridItem.Cells[3].Controls[1];
string selectedValue =
((DataGridUser)this.userList[index]).userRole;
//Check if the program is in edit or create
//If it is in edit, disable the datagrid item row and do not add
PM as dropdownlist item.
if ("ProgramEdit" == programModeValue)
{
if(selectedValue == "PM")
{
myDDList.Items.Add("PM");
DemoGridItem.Enabled = myDDList.Enabled = false;
myDDList.Items.FindByText(((DataGridUser)this.user List[index]).userRole).Selected
= true;
//myDDList.SelectedValue
=((DataGridUser)this.userList[index]).userRole;
} //if the role is null which is a bug in DB
else if (selectedValue == "")
{
myDDList.Items.Add("Sub PM");
myDDList.Items.Add("CBA");
myDDList.Items.Add("Stake Holder");
}
else //since we are in edit mode, add all except PM
{
myDDList.Items.Add("Sub PM");
myDDList.Items.Add("CBA");
myDDList.Items.Add("Stake Holder");
myDDList.Items.FindByText(((DataGridUser)this.user List[index]).userRole).Selected
= true;
//myDDList.SelectedValue
=((DataGridUser)userList[index]).userRole;
}
}
else //we are in create mode, add all the values to the list.
{
myDDList.Items.Add("PM");
myDDList.Items.Add("Sub PM");
myDDList.Items.Add("CBA");
myDDList.Items.Add("Stake Holder");
//set the selected value
myDDList.Items.FindByText(((DataGridUser)this.user List[index]).userRole).Selected
= true;
//myDDList.SelectedValue
=((DataGridUser)userList[index]).userRole;
}
index++;
}

Hope it is readable.

Thanks

Vijay
 
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
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
ajax cascading dropdown: second dropdown disabled acadam ASP .Net 0 12-27-2006 10:59 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth ASP .Net Datagrid Control 0 04-05-2005 03:58 AM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM



Advertisments