dropdownlist in datagrid.

J

Joriz

ive been trying to experiment on dropdownlist in a grid..i cannot get
anything to work...i tried to have some code in the editcommand using
the Findcontrol but its really frustrating ...

anybody is kind enough to help out..

TIA
 
A

ashelley

ive been trying to experiment on dropdownlist in a grid..i cannot get
anything to work...i tried to have some code in the editcommand using
the Findcontrol but its really frustrating ...

anybody is kind enough to help out..

TIA

Here's my example:

<asp:TemplateColumn SortExpression="STE" HeaderText="State">
<ItemTemplate>
<asp:Label Runat="server" Text='<%#
((SortedList)Session["stateTypes"])[(((System.Data.DataRowView)Container.DataItem)["STE"])]
%>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" DataSource='<%#
((SortedList)Session["stateTypes"]) %>' SelectedIndex='<%#
((SortedList)Session["stateTypes"]).IndexOfKey(((System.Data.DataRowView)Container.DataItem)["STE"])
%>' DataValueField="Key" DataTextField="Value" ID="ddlState">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>


and i have something like this in my codebehind when the page loads
up.

stateTypes = new SortedList();
stateTypes.Add("","");
stateTypes.Add("W","Waiting");
stateTypes.Add("H","On Hold");
stateTypes.Add("I","In Process");
Session["stateTypes"] = stateTypes;


hope this helps.

-Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top