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

Multiple slides in Radgrid, determining which fired?

1 Answer 96 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Brooks Talley
Top achievements
Rank 1
Brooks Talley asked on 01 Sep 2008, 06:15 AM
I've got a Radgrid with about 20 rows, each one of which has a RadSlider in an ItemTemplate, databound with DataBinder.Eval.   I have the AutoPostback property set to true, and have a RadSlider1_ValueChanged function in my codebehind.   All that works.

However, I can't find a way to differentiate *which* slider had its value changed.  I know the new value, but that doesn't do a lot of good when there were so many old values.

ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowSorting="False" 
        AutoGenerateEditColumn="True" ShowGroupPanel="false" AutoGenerateColumns="False" 
        AllowAutomaticUpdates="True" Skin="WebBlue" OnNeedDataSource="RadGrid1_NeedDataSource" 
        OnUpdateCommand="RadGrid1_UpdateCommand"
        <MasterTableView GroupsDefaultExpanded="true" GroupHeaderItemStyle-CssClass="custom_GroupHeader" 
            CommandItemDisplay="None" EditMode="InPlace"
            <GroupByExpressions> 
                <telerik:GridGroupByExpression> 
                    <SelectFields> 
                        <telerik:GridGroupByField FieldName="CategoryName" FieldAlias="Category" FormatString="{0}" 
                            HeaderValueSeparator=": " /> 
                    </SelectFields> 
                    <GroupByFields> 
                        <telerik:GridGroupByField FieldAlias="CategoryOrder" FieldName="CategoryOrder" /> 
                    </GroupByFields> 
                </telerik:GridGroupByExpression> 
            </GroupByExpressions> 
            <Columns> 
                <telerik:GridBoundColumn DataField="AttributeName" HeaderText="Attribute" SortExpression="AttributeName" 
                    UniqueName="AttributeName" ReadOnly="True" /> 
                <telerik:GridTemplateColumn DataField="Rating" HeaderText="How Much?" UniqueName="Rating"
                    <ItemTemplate> 
                        <telerik:RadSlider ID='RadSlider1' runat="server" MinimumValue="-3" MaximumValue="3" 
                            AutoPostBack="true" OnValueChanged="RadSlider1_ValueChanged" SlideStep="1" Skin="WebBlue" 
                            Value='<%# DataBinder.Eval(Container.DataItem, "Rating") %>' Orientation="Horizontal" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 

C#:
        protected void RadSlider1_ValueChanged(object sender, EventArgs e) 
        { 
            Telerik.Web.UI.RadSlider myControl = (Telerik.Web.UI.RadSlider)sender; 
            Int32 newValue = myControl.Value; 
 
        } 

....There has to be some way to get back to the data from the original row, right?



1 Answer, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 02 Sep 2008, 03:41 PM
You can save the primary key value in the RadSlider.Tooltip property,e.g.
<telerik:GridTemplateColumn DataField="Value" UniqueName="Value">  
                    <ItemTemplate> 
                       <telerik:RadSlider ID="RadSlider1" runat="server"  Enabled="true" Value='<%#Eval("Value")%>'   
                       OnValueChanged="RadSlider1_ValueChanged" AutoPostBack="true" ToolTip='<%#Eval("ID") %>' 
                       /> 
                     </ItemTemplate> 
                    <EditItemTemplate> 
                        <telerik:RadSlider ID="RadSlider2" runat="server"  Enabled="true" Value='<%# Bind("Value")%>' /> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
Codebehind:
protected void RadSlider1_ValueChanged(object sender, EventArgs e)    
    {    
            Telerik.Web.UI.RadSlider myControl = (Telerik.Web.UI.RadSlider)sender;    
           // Int32 newValue = myControl.Value;    
            Label1.Text = myControl.ToolTip; //You can get the row by this value 
              
    }   


BTW, You can put the slider in the grid declaration and update the data directly, e.g.:
<telerik:GridTemplateColumn DataField="Value" UniqueName="Value">  
                    <ItemTemplate> 
                       <telerik:RadSlider ID="RadSlider1" runat="server"  Enabled="false" Value='<%#Eval("Value")%>'/>  
                     </ItemTemplate> 
                    <EditItemTemplate> 
                        <telerik:RadSlider ID="RadSlider2" runat="server"  Enabled="true" Value='<%# Bind("Value")%>' /> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
Tags
Slider
Asked by
Brooks Talley
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or