views:

14

answers:

0

Hi! I am using Dynaic Data template project. There is DetaislView Control in ListDetails.aspx, that automatically generates table with controls, based on Database structure (relations, filed types), like

<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="DetailsDataSource" Visible="false"
DefaultMode="Insert" AutoGenerateInsertButton="true" OnModeChanging="OnDetailsViewModeChanging"
OnPreRender="OnDetailsViewPreRender" OnItemInserted="OnDetailsViewItemInserted">
</asp:DetailsView>

In case when table has some ralation to another table, then DetailsView control generates DropDownLists when I can pick values for adding a new record. By default these DropDownLists have 1st selected value (SelectedIndex=0), but I want to change that default value to another one.

I tried to find DropDownlList, like

   protected void OnDetailsViewPreRender(object sender, EventArgs e)
    {
        foreach (TableRow trow in DetailsView1.Rows)
        {
            foreach (TableCell tcell in trow.Cells)
            {
                foreach (Control c in tcell.Controls)
                {
                    if (c is DynamicControl)
                    {
                        DynamicControl dc = (DynamicControl)c;

                            foreach (Control cdc in dc....)
                        {
                            if (cdc is DropDownList)
                            {
                                DropDownList drp = (DropDownList)cdc;
                                drp.SelectedIndex = ...
                            }
                        }
                    }
                }
            }
        }

    }

But I dont know how to make thing happen