Multiple slides in Radgrid, determining which fired?

2 posts, 0 answers
  1. Brooks Talley
    Brooks Talley avatar
    4 posts
    Member since:
    Jul 2008

    Posted 01 Sep 2008 Link to this post

    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?



  2. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 02 Sep 2008 Link to this post

    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> 
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top