Thursday, March 10, 2005

Dropdown Controls in Repeater Web Control

A repeater control which contains around 4 to 5 rows and in each row, there will be a dropdown control. On selection of dropdown, the value in selected dropdown has to be retrieved, stating which row and which dropdown selected. We thought about various options to resolve this issue, and nothing seems to work and finally we managed to find this roundabout for this issue. Steps are as below:

1. In the Itemdatabound event of the repeater control, create the SelectedIndexChanged event of the dropdown.

DropDownList MyList = (DropDownList) e.Item.FindControl ("CN");
MyList.SelectedIndexChanged += new EventHandler (CN_SelectedIndexChanged);

2. On selection of dropdown in repeater control, in the corresponding SelectedIndexChanged event, typecast the sender as dropdown and retrieve the selected item value.

Private void CN_SelectedIndexChanged (object sender, System.EventArgs e)
DropDownList CL = (DropDownList) sender;
StrChildNumber = CL.SelectedItem.Value;

In Datagrid, for fetching the rowindex of the selected dropdownlist,
TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem
int index = item.ItemIndex;
string content = item.Cells[0].Text;

The index variable fetches the rowindex, and
the Content variable fetches the content in selected dropdown


For retrieving the selected row index of repeater control, it is that we have appended the row index with the dropdown value with a delimiter and later on retrieving the dropdown value, we can split the dropdown value based on the delimiter and selected row index.

Happy Programming...

Infatuation casinos? indorse this latest [url=]casino[/url] enchiridion and hoax evasively online casino games like slots, blackjack, roulette, baccarat and more at .
you can also into our untrained [url=]casino[/url] navigate at and thrive in verified substitute !
another corresponding unequivocally [url=]casino spiele[/url] interdict of events is , in fearfulness german gamblers, heyday unrestrained online casino bonus.
Hurrah! At last I got a blog from where I can genuinely
get valuable data regarding my study and knowledge.
My page ... convert centimeters
Post a Comment

This page is powered by Blogger. Isn't yours?