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

[Solved] Set selectedIndex based on GridCell in EditFormTemplate

1 Answer 111 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ingimar Andresson
Top achievements
Rank 1
Ingimar Andresson asked on 02 Jun 2009, 07:45 AM
Hi I have a RadGrid with ObjectDataSource who binds to DataSet Table. It works...my Grid populates correctly. The I have FormTemplate for Updating/Insert new record. There I have 4 different RadComboBox controls.....with i populate with following DataBinding:

    protected void gwTeam_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (!(e.Item is GridEditFormItem) || !e.Item.IsInEditMode) return
 
        var child = e.Item as GridEditFormItem; 
        GridDataItem parent = child.ParentItem; 
        GridColumn col; 
 
        var season = child.FindControl("cbSeason"as RadComboBox; 
        var teamName = child.FindControl("tbName"as RadTextBox; 
        var playfield = child.FindControl("cbPlayfield"as RadComboBox; 
        var teamleader = child.FindControl("cbTeamLeader"as RadComboBox; 
        var category = child.FindControl("cbCategory"as RadComboBox; 
        if(season == null || teamName == null ||  playfield == null || teamleader == null || category == null
        { 
            Response.Write("Unable to find control"); 
        } 
        else 
        { 
            season.DataSource = dsAsk.Season; 
            season.DataValueField = "SeasonID"
            season.DataTextField = "SeasonYear"
            season.DataBind(); 
            col = gwTeam.MasterTableView.GetColumnSafe("Säsong"); 
            season.SelectedValue = col.ToString();// parent["Säsong"].Text; 
 
            teamName.Text = parent["TeamName"].Text; 
 
            playfield.DataSource = dsAsk.Playfield; 
            playfield.DataValueField = "PlayfieldID"
            playfield.DataTextField = "PlayfieldName"
            playfield.DataBind(); 
            col = gwTeam.MasterTableView.GetColumnSafe("Spelplan"); 
            playfield.SelectedValue = col.ToString();// parent["Spelplan"].Text; 
 
            teamleader.DataSource = dsAsk.TeamLeader; 
            teamleader.DataValueField = "TeamLeaderID"
            teamleader.DataTextField = "TeamLeaderName"
            teamleader.DataBind(); 
            col = gwTeam.MasterTableView.GetColumnSafe("Lagledare"); 
            teamleader.SelectedValue = col.ToString();// parent["Lagledare"].Text; 
            //teamleader.Text = parent["TeamLeaderID"].Text; 
 
            category.DataSource = dsAsk.TeamCategory; 
            category.DataValueField = "TeamCategoryID"
            category.DataTextField = "TeamCategory"
            category.DataBind(); 
            col = gwTeam.MasterTableView.GetColumnSafe("Serie"); 
            category.SelectedValue = col.ToString();// parent.DataSetIndex; 
            //category.Text = parent["TeamCategoryID"].Text; 
        } 
    } 

what i need is to get/set SelectedIndex or Value on the ComboBox controls based on value in the comparing column in the Grid??

I have read and tried different methods in Telerik Help library but nothing works.....yet.
Any suggestions??

Regards

//Ingimar Andresson

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 05 Jun 2009, 11:28 AM
Hello Ingimar,

I've attached a simple page based on your code to demonstrate the needed approach. Please download it and give it a try.

Regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Ingimar Andresson
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or