Welcome Guest Search | Active Topics | Sign In | Register

how to add already defined dropdown list to <EditorTemplate> of custom column Options
Angel
Posted: Monday, November 1, 2010 6:20:59 PM
Rank: Member
Groups: Member

Joined: 11/1/2010
Posts: 18

i have already defined accountdrop dropdown list. I want to add this to custom column of grid.
Empty dropdown is displaying when i write code like this:

<eo:CustomColumn HeaderText="DimMember" Name="Member" ClientSideEndEdit="on_end_edit">
<EditorTemplate>
<asp:DropDownList ID="AccountDrop" runat="server" Width="150px" >
</asp:DropDownList>
</EditorTemplate>
</eo:CustomColumn>
eo_support
Posted: Monday, November 1, 2010 8:02:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You will need to either statically declare your items in between <asp:DropDownList> and </asp:DropDownList>, or write code to add items. If you write code to add items, you will need to get a reference to the DropDownList first. You can find more details on that in this post:

http://www.essentialobjects.com/forum/postst4991_Retrieve-control-object-id-from-grid.aspx

That post provided sample code to get a reference to a TextBox control in the EditorTemplate. You just change "TextBox" to "DropDownList" and you will have a reference to your DropDownList control. Once you have a reference to the control, you can call method/properties on the control to do anything you'd like to do.

Thanks!
Angel
Posted: Tuesday, November 2, 2010 9:58:51 AM
Rank: Member
Groups: Member

Joined: 11/1/2010
Posts: 18

here is my code:

EO.Web.CustomColumn col = (EO.Web.CustomColumn)EntryGrid.Columns[2];

DropDownList DDL = (DropDownList)col.EditorInstance.FindControl("SelectMember");

DDL = AccountDrop; //AccountDrop is an already defined dropdown list


in the output I am getting empty dropdown list. please help me on this.
eo_support
Posted: Tuesday, November 2, 2010 10:07:35 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can not set DDL directly to your AccountDrop. You must add items to DDL. DDL is like a wall cabinet, it's there for you to use, but you can only fill it, you can not move it. In your case, you would fill DDL the same way as you fill AccountDrop, or write some code to copy items from AccountDrop to DDL.

This is not anything particular to our controls. It's very much basic principle in programming. To modify a control, you get a reference to a control and then call method/property on that control. You almost never assign control reference directly specifically in ASP.NET because it only changes the pointer but nothing else.

Thanks
Angel
Posted: Tuesday, November 2, 2010 11:56:48 AM
Rank: Member
Groups: Member

Joined: 11/1/2010
Posts: 18

Thank you very much. I followed as you suggested and it worked and displaying data in Dropdown list. But now I am getting below error even I am selecting the value in the dropdown list.

Microsoft JScript runtime error: Object required

My JavaScript

function on_begin_edit(cell)
{
//Get the current cell value
var v = cell.getValue();

//Use index 0 if there is no value
if (v == null)
v = 0;

//Load the value into our drop down box
var dropDownBox = document.getElementById("id");
dropDownBox.value = v;
}
function on_end_edit(cell)
{
//Get the new value from the drop down box
var dropDownBox = document.getElementById("id");
var v = dropDownBox.value;


//Return the new value to the grid
return v;
}


C# Code:

EO.Web.CustomColumn col = (EO.Web.CustomColumn)EntryGrid.Columns[2];

DropDownList DDL = (DropDownList)col.EditorInstance.FindControl("SelectMember");

string id = DDL.ClientID;


ASPX CODE:

<eo:CustomColumn HeaderText="DimMember" ClientSideEndEdit="on_end_edit">
<EditorTemplate>
<asp:DropDownList ID="SelectMember" runat="server" Width="150px">
</asp:DropDownList>
</EditorTemplate>
</eo:CustomColumn>

Please help me on this..

eo_support
Posted: Tuesday, November 2, 2010 12:08:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

There is no correlation between the "id" in local variable "string id" and the "id" in getElementById("id"). They are completely unrelated and it appears that you think they are the same.

If you still have similar problems, you may want to find someone else around you to help you. You have some major issues with general ASP.NET programming and we can not afford to point them out to you one by one. These are basic programming issues and are completely unrelated to our product. We will do our best to point you to the right direction and help you to understand our product, but unfortunately we are not in a position to troubleshoot your code.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.