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

Problem with RadListBox in RadGrid Form Template

8 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 11 Sep 2013, 05:40 PM
Hello. I have a Rad grid and inside of the edit form template I have a radlistbox. When I click the edit button on the column I want to edit I get a TypeError RadListBox is not defined. If I click it again it then loads and works. Please help me with this. It is urgent!

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Sep 2013, 04:23 AM
Hi Will,

Unfortunately I couldn't replicate the issue. Such an error is unexpected in normal scenario. Here is a sample code snippet I tried.

ASPX:
<telerik:RadGrid ID="Radgrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
    AutoGenerateEditColumn="true">
    <MasterTableView>
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <telerik:RadListBox ID="RadListBox1" runat="server">
                    <Items>
                        <telerik:RadListBoxItem Text="1" Value="1" />
                        <telerik:RadListBoxItem Text="2" Value="2" />
                        <telerik:RadListBoxItem Text="3" Value="3" />
                    </Items>
                </telerik:RadListBox>
            </FormTemplate>
        </EditFormSettings>
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Thanks,
Princy.
0
Ganesh
Top achievements
Rank 1
answered on 16 Jun 2014, 05:39 PM
Hi
I'm Completely new to this Toolkit. I just want to bind a radlistbox in a radgrid.

Can any one please help me out in this issue.

Any help would be greatly appreciated. Thank you
0
Princy
Top achievements
Rank 2
answered on 17 Jun 2014, 03:30 AM
Hi Ganesh,

Please have a look into the sample code snippet to bind a RadListBox in a RadGrid.

ASPX:
<telerik:RadGrid ID="rgrdOrders" runat="server" DataSourceID="SqlDataSource1">
    <MasterTableView>
        <Columns>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <telerik:RadListBox ID="rlstbox" runat="server" DataSourceID="SqlDataSource1" DataTextField="CustomerID" DataValueField="OrderID">
                    </telerik:RadListBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Let me know if you have any concern.
Thanks,
Princy.
0
Ganesh
Top achievements
Rank 1
answered on 17 Jun 2014, 04:43 AM
Hi
First Let me  tell you my problem exactly.

I have a radgrid inside MasteTableView
I have one DetailTable and inside of it I have another DetailTable 
and inside of it I've placed a RadListBox. 

My question is that How to bind it?






0
Princy
Top achievements
Rank 2
answered on 18 Jun 2014, 04:00 AM
Hi Ganesh,

Please try to bind the RadListBox in OnItemDataBound  event of RadGrid.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item.OwnerTableView.Name == "CheckListItems" && e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        RadListBox listBox = (RadListBox)item.FindControl("rlstbox");
        //code for binding RadListBox
        string OrderID = item.GetDataKeyValue("OrderID").ToString();
        listBox.DataSource = GetDataTable("SELECT ProductID FROM [Order Details] WHERE OrderID = " + OrderID);
        listBox.DataTextField = "ProductID";
        listBox.DataBind();
    }
}

Thanks,
Princy.
0
Ganesh
Top achievements
Rank 1
answered on 18 Jun 2014, 11:49 AM
Hi Thanks for your support. It's really help full.
I got stuck in a situation  where my last inner GridTableView holding three columns 1. ID, 2. Name, 3. RadioButton Yes/No(20 rows there currently)
i have a button outside of the grid and I want  to fetch  the ID, RadioButton Value, Parent Table Row ID and It's Parent Table Row ID for all the (20 Rows)

I hope you will definitely solve my issue.

Thank you, thanks for your consideration.
0
Ganesh
Top achievements
Rank 1
answered on 18 Jun 2014, 01:05 PM
I forgot to attach a my design code. Have a look on it. Thank you
0
Princy
Top achievements
Rank 2
answered on 19 Jun 2014, 05:58 AM
Hi Ganesh,

Please try the below c# code snippet to access the inner Details Table details in External Button OnClick.

C#:
protected void rbtnFetchDetailTable1_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.Items)
    {
        if (item.OwnerTableView.Name == "CheckListItems")
        {
            {
                GridDataItem dataItem = (GridDataItem)item;
                string UnitPrice = dataItem["ID"].Text;
                string Quantity = dataItem["Name"].Text;
                RadButton toggleButton = (RadButton)dataItem.FindControl("rbtnToggleState");
                string selectedText = toggleButton.SelectedToggleState.Text;
                string parentKey = item.OwnerTableView.ParentItem.GetDataKeyValue("OrderID").ToString();
                string grandParent = item.OwnerTableView.ParentItem.OwnerTableView.ParentItem.GetDataKeyValue("CustomerID").ToString();
            }
        }
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Will
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ganesh
Top achievements
Rank 1
Share this question
or