Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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:

Posted

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

Posted

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;

Asif Raza Ashraf

Senior Software Engineer

Electronic Solutions Pakistan

Islamabad

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...