dropdownlist in datagrid.

dropdownlist in datagrid.

Post by googl » Wed, 30 Jun 2004 08:59:41


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
 
 
 

dropdownlist in datagrid.

Post by ashelle » Wed, 30 Jun 2004 09:07:33

On 28 Jun 2004 16:59:41 -0700, XXXX@XXXXX.COM (Joriz)



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

 
 
 

dropdownlist in datagrid.

Post by Saravana [ » Wed, 30 Jun 2004 13:15:13

Check out this article,
http://www.yqcomputer.com/
boutASPNETDataGridServerControl.asp?frame=true#vbtchtopquestionsaboutaspnetd
atagridservercontroleditingmultiplerows