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

dropdownlist selectedvalue in radgrid

4 Answers 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard Clarke
Top achievements
Rank 1
Richard Clarke asked on 15 Jul 2010, 11:04 AM
I am trying to get the selected value of a DropDownList which is created in GridTemplateColumn.

<telerik:GridTemplateColumn HeaderText="Style" UniqueName="STYLE">
    <ItemTemplate>
        <asp:DropDownList runat="server" ID="ddl_style" AppendDataBoundItems="true" AutoPostBack="true" >
            <asp:ListItem Text="a" Value="1"></asp:ListItem>
            <asp:ListItem Text="b" Value="2"></asp:ListItem>
            <asp:ListItem Text="c" Value="3"></asp:ListItem>
        </asp:DropDownList>
    </ItemTemplate>
</telerik:GridTemplateColumn>

I set the selectedvalue on itemDataBound,

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
 
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim ddl As DropDownList = DirectCast(item("STYLE").FindControl("ddl_style"), DropDownList)
        ddl.SelectedValue = ViewState("styleId")
        ddl.DataBind()
    End If
 
End Sub

This does get fired when a change is made in the DropDownList, however it is alos the previous value (i check prior to setting it again).  Also this does not seem like the best place for me to check this, as this is where i set the selectedValue.

Any help on this would be much appreciated.

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Jul 2010, 01:19 PM
Hi Richard,

You can go through the following link and see if it helps to achieve your goal:
http://www.telerik.com/community/forums/aspnet-ajax/grid/ho-to-get-radgrid-row-s-cell-values-on-drop-down-conrol-s-select-changed-event.aspx

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Clarke
Top achievements
Rank 1
answered on 15 Jul 2010, 02:00 PM
Thank you for your reply.

I have added the onSelectedIndexChanged, however it never gets fired.  Autopostback is set to true on the dropdownlist.  I am writing in VB
0
mabs
Top achievements
Rank 1
answered on 16 Jul 2010, 10:22 AM
If any one can help with this it would be much appreciated. (I am looking after this instead of Richard)
<telerik:GridTemplateColumn HeaderText="Style" UniqueName="STYLE">
    <ItemTemplate>
        <asp:DropDownList runat="server" ID="ddl_style" AppendDataBoundItems="true" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
            <asp:ListItem Text="Commission" Value="1"></asp:ListItem>
            <asp:ListItem Text="Fee" Value="2"></asp:ListItem>
            <asp:ListItem Text="Other" Value="4"></asp:ListItem>
        </asp:DropDownList>
    </ItemTemplate>
</telerik:GridTemplateColumn>
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
...
    End Sub
0
Pavlina
Telerik team
answered on 19 Jul 2010, 01:52 PM
Hi Richard,

I followed your scenario in order to replicate the described behavior but no avail. Please find the attached sample and let me know how it works on your end and if I missed something from your logic.

Let us know if we could help you further.

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Richard Clarke
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Richard Clarke
Top achievements
Rank 1
mabs
Top achievements
Rank 1
Share this question
or