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

selectindexchange for radgrid

2 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neela
Top achievements
Rank 1
Neela asked on 10 Feb 2012, 11:45 AM
The grid is loaded with data and while selecting a row from the grid, the data is not displayed in the corresponding controls.Using trace, I found that SelectIndexChange event is not fired. My code is below






<telerik:RadGrid runat="server" ID="rgoptionexercisetype" AllowPaging="True" AllowSorting="True"
                        AllowFilteringByColumn="True" CellSpacing="2" GridLines="None" CssClass="Grid_Master"
                        Skin="Office2010Black"  OnSelectedIndexChanged="rgoptionexercisetype_SelectedIndexChanged"
                        ClientSettings-EnablePostBackOnRowClick="True" >
                        <MasterTableView DataKeyNames="optionexercisetypecode" ClientDataKeyNames="optionexercisetypecode">
                            <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                </EditColumn>
                            </EditFormSettings>
                            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                            </ExpandCollapseColumn>
                            <PagerStyle Mode="NumericPages" AlwaysVisible="True" EnableSEOPaging="True" />
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="True" AllowColumnsReorder="True"  Selecting-AllowRowSelect="true"
                             ReorderColumnsOnClient="True"  >
                            <DataBinding SelectMethod="GetDataAndCount" Location="GridWcfService.svc" SortParameterType="Linq"
                                FilterParameterType="Linq">
                            </DataBinding>
                            <Selecting AllowRowSelect="True" />
                        </ClientSettings>
                        <HeaderStyle HorizontalAlign="Center" ForeColor="White" />
                        <FilterItemStyle HorizontalAlign="Center" />
                        <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="True"
                            EnableSEOPaging="True" />
                        <FilterMenu EnableImageSprites="False">
                        </FilterMenu>
                    </telerik:RadGrid>



 protected void Page_Load(object sender, EventArgs e)
        {
          
            if (!IsPostBack)
            {
                
                WROptionExerciseType.Service1 cl = new WROptionExerciseType.Service1();
                rgoptionexercisetype.DataSource = new string[] { };
                rgoptionexercisetype.DataSource = cl.SelectOptionExcerciseType();//loading the record in the grid
                rgoptionexercisetype.DataBind();
                ViewState["OPT"] = cl.SelectOptionExcerciseType();
                GridColumn column = rgoptionexercisetype.MasterTableView.GetColumnSafe("optionexercisetypecode"); //hiding the auto-generated column
                if (column != null)
                {
                    column.Visible = !column.Visible;
                    rgoptionexercisetype.Rebind();
                }
            }


  protected void rgoptionexercisetype_SelectedIndexChanged(object sender, EventArgs e)
        {
            //while selecting the row in the grid, the data are displayed in the corresponding controls

            rgoptionexercisetype.DataSource=ViewState["OPT"];
            if (e.ToString() != String.Empty || e.ToString() != "")
            {
                this.lbloptionexercisetypecode.Text = rgoptionexercisetype.SelectedItems[0].Cells[2].Text;
                this.rtxtoptionexerciseType.Text = rgoptionexercisetype.SelectedItems[0].Cells[3].Text;
                this.rcboptionexcercisestatus.SelectedValue = rgoptionexercisetype.SelectedItems[0].Cells[4].Text;
                this.rtxtdisplayorder.Text = rgoptionexercisetype.SelectedItems[0].Cells[5].Text;
            }
        }










2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 13 Feb 2012, 04:37 PM
Hello Neela,

Do use Advanced data-binding for your grid as opposed to Simple data-binding and set
rgoptionexercisetype.ClientSettings.EnablePostbackOnRowClick = true;

Hope it helps.

Regards, Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tsvetoslav
Telerik team
answered on 13 Feb 2012, 04:37 PM
Hello Neela,

Do use Advanced data-binding for your grid as opposed to Simple data-binding and set
rgoptionexercisetype.ClientSettings.EnablePostbackOnRowClick = true;

Hope it helps.

Regards, Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Grid
Asked by
Neela
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or