A
andy
I have a set of maintenance forms which represent a parent child
relationship.
In the parent form you can set a value 1 to 5.
Say the user chooses 3.
In the child form the user should only get to choos from 1, 2 or 3 in
a dropdownlist.
This is within a formview.
If I declaratively add items 1 through 5 then everything works fine.
My problems started when I tried to switch to programmatically adding
the entries.
I get various errors depending on what event I stick my code into but
essentially I'm unable to find a page event whiere the dropdownlist
control can be found (FindControl) but which is before the
databinding
event.
Any ideas on how to get round this problem?
example code
protected void Page_Load(object sender, EventArgs e)
{
Key_Risk_Id_txt.Text = Request.QueryString["Risk_Id"];
Risk Current_Risk = new
Risk(Convert.ToInt32(Request.QueryString["Risk_Id"]));
int i;
DropDownList ddl =
(DropDownList)fvwMitigation.FindControl("S_Commercial_ddl");
for (i = 1; i <=
Convert.ToInt32(Current_Risk.S_Commercial); i++)
{
ddl.Items.Add(new ListItem(Convert.ToString(i),
Convert.ToString(i)));
}
}
relationship.
In the parent form you can set a value 1 to 5.
Say the user chooses 3.
In the child form the user should only get to choos from 1, 2 or 3 in
a dropdownlist.
This is within a formview.
If I declaratively add items 1 through 5 then everything works fine.
My problems started when I tried to switch to programmatically adding
the entries.
I get various errors depending on what event I stick my code into but
essentially I'm unable to find a page event whiere the dropdownlist
control can be found (FindControl) but which is before the
databinding
event.
Any ideas on how to get round this problem?
example code
protected void Page_Load(object sender, EventArgs e)
{
Key_Risk_Id_txt.Text = Request.QueryString["Risk_Id"];
Risk Current_Risk = new
Risk(Convert.ToInt32(Request.QueryString["Risk_Id"]));
int i;
DropDownList ddl =
(DropDownList)fvwMitigation.FindControl("S_Commercial_ddl");
for (i = 1; i <=
Convert.ToInt32(Current_Risk.S_Commercial); i++)
{
ddl.Items.Add(new ListItem(Convert.ToString(i),
Convert.ToString(i)));
}
}