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

Update of nestedview

2 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ahrensberg
Top achievements
Rank 1
Ahrensberg asked on 10 Dec 2009, 08:07 AM
Hi guys,

I have a radgrid containing a nestedview. This view is filled with data by e.g.:

<asp:Label ID="LblDeliveryType" runat="server"><%# Eval("DeliveryTypeId")%></asp:Label> 

Above is an ID for a deliverytype, but I want to exchange this ID with some describing text. I have tried to do this in eventhandlers as OnItemDataBound and OnItemCommand at the RadGrid, OnPageViewCreated in my RadMultiPage, and some other places, but in these eventhandlers the data isn't filled out yet, and therefore I can't update the fields.

Any ideas what to do?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Dec 2009, 08:44 AM
Hi Ahrensberg,

aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" runat="server" OnItemDataBound="RadGrid1_ItemDataBound" >             
     <MasterTableView DataSourceID="SqlDataSource1" >                   
               <NestedViewTemplate>   
                        <asp:Label ID="LblDeliveryType" runat="server"><%# Eval("DeliveryTypeId")%></asp:Label> 
                   .... 




c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridNestedViewItem) 
        { 
            GridNestedViewItem nestedItem = (GridNestedViewItem)e.Item; 
            Label lbl = (Label)nestedItem.FindControl("LblDeliveryType"); 
            lbl.Text = "My Custom Text";             
        } 
    } 

Thanks
Princy.
0
Ahrensberg
Top achievements
Rank 1
answered on 10 Dec 2009, 09:14 AM
Hi Princy,

First of all, thanks for the quick reply!

I have tried something similar, but the problem is that the label is empty at this point. What I want is something like this:

if (e.Item is GridNestedViewItem) 
    GridNestedViewItem nestedItem = (GridNestedViewItem)e.Item; 
    Label lbl = (Label)nestedItem.FindControl("LblDeliveryType"); 
 
    string content = ""
    if (!lbl.Text.Equals("")) 
    { 
        switch ((DeliveryTypes) Convert.ToInt32(lbl.Text)) 
        { 
            case DeliveryTypes.DayToDay: 
                content = "Day-to-day"
                break; 
 
            case DeliveryTypes.Weekday: 
                content = "Weekday"
                break; 
        } 
    } 
 
    lbl.Text = content

But the lbl.Text is always empty, and therefore the "if (!lbl.Text.Equals(""))" is never entered. :-(

Best regards,
Kenneth




Tags
Grid
Asked by
Ahrensberg
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ahrensberg
Top achievements
Rank 1
Share this question
or