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

Cascading Updates

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 07 Jun 2010, 05:04 PM
Hello,

I Insert Mode on a detail level I have two dropdownlists and textbox. When a selection is made in the dropdownlist I cascade populate the other list but also need to populate the textbox with relative data.

In the OnIndexChanged event I cannot find access to the textbox item for update.

How do I go about accomplishing such as this?

Thank you,

Steve O...

 

private void list_SelectedIndexChanged(object sender, System.EventArgs e)

 

{

 

GridEditableItem editedItem = (sender as DropDownList).NamingContainer as GridEditableItem;

 

 

DropDownList ddList = editedItem["AgencyId"].Controls[0] as DropDownList;

 

SqlDataSource8.SelectCommand =

"select AgencyId, AgencyShort from cimt_lu_agencies a, cimt_v_resources r where r.agency = a.agencyshort and r.name = '" +

 

(editedItem[

"ResourceId"].Controls[0] as DropDownList).SelectedItem.Text + "'";

 

ddList.DataSource = SqlDataSource8;

ddList.DataBind();

}

1 Answer, 1 is accepted

Sort by
0
JSON
Top achievements
Rank 1
answered on 09 Jun 2010, 03:06 PM

Resolved the issue myself by creating reference to the controls needing update in the ItemCreated event using class variables.
Was then able to cascade populate these controls in the drop down's Item Index Changed event. May not be the recomended solution but it worked for me.

Thnaks,

Steve O...

 

 

public partial class EditIncidents : System.Web.UI.Page

 

 

 

 

 

{

 

    TextBox agency;

 

 

    TextBox callsign;

 

 

}

protected
void RadGrid2_ItemCreated(object sender, GridItemEventArgs e)

 

{   

 

 

    DropDownList list = (e.Item as GridEditableItem)["ResourceId"].Controls[0] as DropDownList;

 

    
    list.AutoPostBack =

true;

 

    list.SelectedIndexChanged +=

new System.EventHandler(this.list_SelectedIndexChanged);

 

    callsign = (e.Item

as GridEditableItem)["CallSign"].Controls[0] as TextBox;

 

    callsign.Enabled =

false;

 

    
    agency = (e.Item

as GridEditableItem)["Agency"].Controls[0] as TextBox;

 

    agency.Enabled =

false;
}

 

 

private void list_SelectedIndexChanged(object sender, System.EventArgs e)

 

{

 

    GridEditableItem editedItem = (sender as DropDownList).NamingContainer as GridEditableItem;

 

 

    int id = Convert.ToInt32((editedItem["ResourceId"].Controls[0] as DropDownList).SelectedValue);

 

 

    
    StoredProcedure
sp = new StoredProcedure("Get_Resource_Details");

 

    
    sp.Command.AddParameter(

"@id", @id, DbType.Int32);

 

    sp.Command.AddOutputParameter(

"@callsign");

 

    sp.Command.AddOutputParameter(

"@agency");

 

 

    sp.Execute();

    
    callsign.Text =

Convert.ToString(sp.OutputValues[0]).Trim();

 

    agency.Text =

Convert.ToString(sp.OutputValues[1]);

 

}

Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
JSON
Top achievements
Rank 1
Share this question
or