This is a migrated thread and some comments may be shown as answers.

Possible to have DropDown column with different values per row?

1 Answer 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
EmpowerIT
Top achievements
Rank 2
EmpowerIT asked on 31 Jan 2008, 04:12 AM
Hi,
I was wondering if it is possible to have a drop down column which has different values in the list depending on the row?

E.G I have a record which consists of a RecId, name and a status. Name is just a plain text, RecId is the primary key (autogenerated number) and status is a foregin key to another table.

The other table is in the format of Id, RecId,StatusName.

I have a datasource which needs to select from this status table where RecId is the value of the current row.

Is it possible? Is there some event where I can set the default value for the SqlDataSource select paramater to allow this behaviour?
Thanks,

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 31 Jan 2008, 11:57 AM
Hello EmpowerIT,

You can achieve this using GridTemplateColumn with regular drop down where you can point desired DataSource in ItemCreated. Here is an example:

<MasterTableView DataKeyNames="MyID">
    <Columns>
        <telerik:GridTemlateColumn>
          <ItemTemplate>
              <asp:DropDownList ID="DropDownList1" runat="server" />
...

if(e.Item is GridDataItem)
{
    string myKeyValue = ((GridDataItem)e.Item).GetDataKeyValue("MyID").ToString();
   if(myKeyValue == "Something")
   {
       DropDownList DropDownList1 = (DropDownList)e.Item.FindControl("DropDownList1");
       DropDownList1.DataSource = MySource;
       ...
   }
}

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
EmpowerIT
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Share this question
or