Ido Posted October 12, 2003 Posted October 12, 2003 I want the user to select from a closed list (when editing a column in a DataGrid) - so a textbox is not good for me. Is it posiible to use Combox instead ?? Thanks. Quote
Moderators Robby Posted October 12, 2003 Moderators Posted October 12, 2003 with a TemplateColumn and EditItemTemplate you can place almost any control into a column. Quote Visit...Bassic Software
Ido Posted October 13, 2003 Author Posted October 13, 2003 Yes thanks! Now when i click "Edit" i get a dropdownList but it's empty! I tried eveything (i think). in the property window of the dropdownlist (datagris -> right click->Edit Template ) i assigned the correct datasource. i also try to go by "databinds ..." option of the dropdownList , tehn i choosed: DataBinder.Eval(Container, "DataItem.title") => this is the first time i have something in the dropdownList, but it is the cell value, 1 row for each letter... (later i couldn't find "title" under container, and i don't know why..) i didn't find yet, how to load all the item of a table database (i use access) to a dropdownList. :mad: :confused: :mad: Quote
aah_what Posted October 15, 2003 Posted October 15, 2003 asp.net datagrid conditional formatting Hi, I want to use a datagrid to display email message headers but how can I display the envelopes to show new or read? The read is returned as an integer. Any Ideas? Matt Quote
AsifCh Posted October 15, 2003 Posted October 15, 2003 Use the following code in the Template Column tag of the data grid <ItemTemplate> <asp:Label Text='<%# DataBinder.Eval(Container.DataItem, "ddlvalue") %> ' runat="server" ID="Label1"/> </ItemTemplate> <EditItemTemplate> <asp:DropDownList Runat="server" ID="myDDL" /> </EditItemTemplate> to insert the values in the Data grid in edit mode use the function private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemType==ListItemType.EditItem) { DataRowView drv= (DataRowView)(e.Item.DataItem); String currentType=drv["ddlvalue"].ToString(); DropDownList ddl=(DropDownList)e.Item.FindControl("myDDL"); ddl.Items.Add("Item 1"); ddl.Items.Add("item 2"); ListItem item=ddl.Items.FindByText("Item 1"); if(item!= null) item.Selected=true; } } use the following code in the Update command of the Data Grid DropDownList ddl = (DropDownList)e.Item.Cells[5].Controls[1]; String value= ddl.SelectedItem.Text; Quote Asif Raza Ashraf Senior Software Engineer Electronic Solutions Pakistan Islamabad
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.