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

Conditional dropdown in cell

2 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jesse
Top achievements
Rank 1
Jesse asked on 07 Aug 2014, 09:56 PM
Hello,

Is it possible to have a cell in the table be a dropdown only if the value is a certain value? I want to allow the user to change the value under certain circumstances.

There are several mailing status: Created, Mailed, Delievered, and Lost

If the value is 'Lost', I want to give the ability to change it to Mailed or Delivered. Otherwise, I want to display the status as a label.



Is this possible?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Aug 2014, 04:06 AM
Hi Jesse,

You can try the following code snippet to add a DropDownList for some rows of radgrid.

ASPX:
<telerik:GridBoundColumn DataField="Status" HeaderText="Status" UniqueName="Status" />

C#:
protected void rgrdSample_ItemDataBound(object sender, GridItemEventArgs e)
{      
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = (GridDataItem)e.Item;
        if (dataItem["Status"].Text == "Lost")
        {
            DropDownList ddlStatus = new DropDownList();
            ddlStatus.ID = "ddlStatus";
            ddlStatus.DataSource = dtStatus;
            ddlStatus.DataTextField = "Status";
            ddlStatus.DataValueField = "Status";          
            ddlStatus.DataBind();
            dataItem["Status"].Controls.Add(ddlStatus);
        }
    }
}

Thanks,
Princy
0
Jesse
Top achievements
Rank 1
answered on 08 Aug 2014, 04:06 PM
Well that wasn't as bad as I thought it would be! Thanks Princy!
Tags
Grid
Asked by
Jesse
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jesse
Top achievements
Rank 1
Share this question
or