Vraag : Formview - Uitzondering System.NullReference wanneer het gebruiken van FindControlRecursive

Ik heb een formview met een puntmalplaatje, geef puntmalplaatje uit, en neem puntmalplaatje op. Ik heb een dropdownlist die ik met erachter gegevens via de code wil bevolken.  Hieronder is de code en paginaprijsverhoging.  Ik kan de waarde voor de controle in het puntmalplaatje plaatsen.  Nochtans, wordt de controle niet gevonden met succes in uitgeeft puntmalplaatje.  Ik heb formview modechanged, formview puntbevel, en wijze veranderende gebeurtenissen geprobeerd.  De werken van DdlCurrFacilityread.  De ddlCurrFacilitycode werkt niet.  Ik ben open aan suggestions.

DropDownList ddlCurrFacilityread = FindControlRecursive (FormView1, „ddlCurrFacilityread“) als DropDownList;
DropDownList ddlCurrFacility = FindControlRecursive (FormView1, „ddlCurrFacility“) als DropDownList;
ddlCurrFacilityread.SelectedValue = Master.FacilityName;
ddlCurrFacility.SelectedValue = Master.FacilityName;

public statische Controle FindControlRecursive (/>ol wortel Contr {
als ((root.ID! = verklaar) && (identiteitskaart root.ID ==) nietig) keer wortel terug;

foreach (Controle CTRL in wortel. Controle)
{/> gevonden Controle
identiteitskaart CTRL, als (gevonden! = ongeldige) gevonden terugkeer; /> ongeldige terugkeer
}
}

Source“ OnItemInserted= " FormView1_ItemInserted“ OnItemUpdated= " FormView_ItemUpdated " OnItemDeleted= " FormView_ItemDeleted " DataKeyNames= " RowNum, RowVersion " >emTemplate>
Height= " 450px“ Width= " 700px " >


General

r><td>
l“
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SubstanceUseAtTimeOfCrime“)) %>'> No>Item Value= " 1 " >Yesm>

<td>
ID= " ddlSecurityLevelRead“ Enabled=false runat= " server“ Width= " 150px " >
Maximum: ListItem>
IntermediateItem>
Minimum: ListItem>
CampusListItem>
Unknown: ListItem>

d>
ID= " ddlArearead“ Enabled=false runat= " server“ Width= " 250px " >


d>

ID= " ddlCurrFacilityread“ Enabled=false runat= " server“ Width= " 250px " >
Northwest: ListItem>
Southeast: ListItem>
: ListItem>
Marshall: ListItem>
Southeast Missouri WoonServices
Fulton: ListItem>



>

ID= " ddlProgramread“ Enabled=false runat= " server“ Width= " 250px " >




d>

ID= " ddlBehaviorread“ Enabled=false runat= " server“ Width= " 150px“ DataSourceID= " SqlDataSource3“
DataTextField= " RiskRating " DataValueField= " RiskRating“ SelectedValue='<%# bindt („CurrentRiskRating“) %>'>

tTemplate>


Crime 1
r><td>
d>
r>
<td>
>
>>
<td>
r>
<td>

SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „MajorCrimeNum_1“)) %>'> No>
Yesm>

d>
r>r>r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_1“) %>' >




e4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatus“) %>' >
Text= " Geprobeerde Misdaad 1: “ Height= " 22px " > RepeatDirection= " Horizontal "
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime1“)) %>'> No>Item Value= " 1 " >Yesm>


>


SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num1“)) %>'> No>Item Value= " 1 " >Yesm>
>


RepeatDirection=Horizontal
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_1 " )) %>'> No>Item Value= " 1 " >Yesm>
>

td>



el>

>


SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_1“)) %>'> No>Item Value= " 1 " >Yesm>
>

</td>



Height= " 191px“ Text='<%# bindt („NarrativeDescriptionNum_1“) %>'>
emplate>


Crime 2
r><td>
d>
r>
<td>
>
><td>
<td>
SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „MajorCrimeNum_2“))%>'> No>Item Value= " 1 " >Yesm>

d>
r>r>r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_2“) %>'>




e4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatusNum_2“) %>' >
Text= " Geprobeerde Misdaad 2: “ Height= " 22px " > RepeatDirection= " Horizontal " SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime2“))%>'> No>Item Value= " 1 " >Yesm>


>
RadioButtonList ID= " rblSex2read“ Enabled=false runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num2“))%>'> No>Item Value= " 1 " >Yesm>
>

RadioButtonList ID= " rblRegister2read“ Enabled=false runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_2 " ))%>'> No>Item Value= " 1 " >Yesm>
>

td>


el>

>
ButtonList ID= " rblFelony2read“ Enabled=false runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_2“))%>'> No>Item Value= " 1 " >Yesm>
>

</td>



Height= " 193px“ Text='<%# bindt („NarrativeDescriptionNum_2“) %>'>
emplate>


Crime 3
r><td>
d>
r>
<td>
>
>>
<td>
r>
<td>
SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „MajorCrimeNum_3“))%>'> No>Item Value= " 1 " >Yesm>

d>
r>r>r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_3“) %>'>




e4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatusNum_3“) %>' >
Text= " Geprobeerde Misdaad 3: “ Height= " 22px " > RepeatDirection= " Horizontal " SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime3“))%>'> No>Item Value= " 1 " >Yesm>


>
RadioButtonListID= " rblSex3read“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num3“))%>'> No>Item Value= " 1 " >Yesm>
>

RadioButtonList ID= " rblRegister3read“ Enabled=false runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_3 " ))%>'> No>Item Value= " 1 " >Yesm>
>

td>



el>

>
ButtonList ID= " rblFelony3read“ Enabled=false runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_3“))%>'> No>Item Value= " 1 " >Yesm>
>

</td>



Height= " 186px“ Text='<%# bindt („NarrativeDescriptionNum_3“) %>'>
emplate>

tton ID= " btnNew“ runat= " server“ Text= " Nieuwe“ CommandName= " Nieuwe“/>
ID= " btnDelete“ runat= " server“ Text= " schrapt“ CommandName= " schrapt“/>Template> Height= " 417px“ Width= " 700px " >


General

r><td>
l“
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SubstanceUseAtTimeOfCrime“)) %>'> No>Item Value= " 1 " >Yesm>

<td>
ID= " ddlSecurityLevel“ runat= " server“ Width= " 150px“ Enabled=false>
Maximum: ListItem>
IntermediateItem>
Minimum: ListItem>
CampusListItem>
Unknown: ListItem>

d>
ID= " ddlArea“ runat= " server“ Width= " 250px " >


d>

ID= " ddlCurrFacility“ runat= " server“ Width= " 250px " >
Northwest: ListItem>
Southeast: ListItem>
: ListItem>
Marshall: ListItem>
Southeast Missouri WoonServices
Fulton: ListItem>



>

ID= " ddlProgram“ runat= " server“ Width= " 250px " >




d>

ID= de " ddlBehavior“ runat= " server“ Width= " 150px“ DataSourceID= " SqlDataSource3“
DataTextField= " RiskRating " DataValueField= " RiskRating“ SelectedValue='<%# bindt („CurrentRiskRating“) %>'>

tTemplate>


Crime 1
r><td>
d>
r>
<td>
><td>
<td>
No>
Yesm>

d>
>
r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_1“) %>' >




DataSourceID= " SqlDataSource4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatus“) %>' >
Text= " Geprobeerde Misdaad 1: “ Height= " 22px " > RepeatDirection= " Horizontal "
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime1“)) %>'> No>Item Value= " 1 " >Yesm>


>

No>Item Value= " 1 " >Yesm>
>


)) %>'> No>Item Value= " 1 " >Yesm>
>

td>


el>

No>Item Value= " 1 " >Yesm>
>

</td>


emplate>


Crime 2
r><td>
d>
Text= " Geprobeerde Misdaad 2: “ Height= " 22px " >
<td>
><td>
<td>
No>Item Value= " 1 " >Yesm>

d>
>
r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_2“) %>'>




DataSourceID= " SqlDataSource4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatusNum_2“) %>' >
RepeatDirection= " Horizontal " SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime2“))%>'> No>Item Value= " 1 " >Yesm>


>
RadioButtonListID= " rblSex2“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num2“))%>'> No>Item Value= " 1 " >Yesm>
>

RadioButtonListID= " rblRegister2“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_2 " ))%>'> No>Item Value= " 1 " >Yesm>
>

td>


el>
ButtonList ID= de " rblFelony2“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_2“))%>'> No>Item Value= " 1 " >Yesm>
>

</td>


emplate>


Crime 3
r><td>
d>
Text= " Geprobeerde Misdaad 3: “ Height= " 22px " >
<td>
><td>
<td>
No>Item Value= " 1 " >Yesm>

d>
>
r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_3“) %>'>




DataSourceID= " SqlDataSource4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatusNum_3“) %>' >
RepeatDirection= " Horizontal " SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime3“))%>'> No>Item Value= " 1 " >Yesm>


>
RadioButtonListID= " rblSex3“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num3“))%>'> No>Item Value= " 1 " >Yesm>
>

RadioButtonListID= " rblRegister3“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_3 " ))%>'> No>Item Value= " 1 " >Yesm>
>

td>


el>
ButtonList ID= de " rblFelony3“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_3“))%>'> No>Item Value= " 1 " >Yesm>
>

</td>


emplate>

tton ID= " btnUpdate“ runat= " server“ Text= " Update“ CommandName= " Update“/>
rtItemTemplate>TabContainer ID= " TabContainer1“ runat= " server“ ActiveTabIndex= " 0“
Height= " 417px“ Width= " 700px " >


General

r><td>
l“
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SubstanceUseAtTimeOfCrime“)) %>'> No>Item Value= " 1 " >Yesm>

<td>
ID= " ddlSecurityLeveli“ runat= " server“ Width= " 150px“ Enabled=false>
Maximum: ListItem>
IntermediateItem>
Minimum: ListItem>
CampusListItem>
Unknown: ListItem>

d>
ID= " ddlAreai“ runat= " server“ Width= " 250px " >


d>

ID= " ddlCurrFacilityi“ runat= " server“ Width= " 250px " >
Northwest: ListItem>
Southeast: ListItem>
: ListItem>
Marshall: ListItem>
Southeast Missouri WoonServices
Fulton: ListItem>



>

ID= " ddlProgrami“ runat= " server“ Width= " 250px " >




d>

ID= de " ddlBehaviori“ runat= " server“ Width= " 150px“ DataSourceID= " SqlDataSource3“
DataTextField= " RiskRating " DataValueField= " RiskRating“ SelectedValue='<%# bindt („CurrentRiskRating“) %>'>

tTemplate>


Crime 1
r><td>
d>
Text= " Geprobeerde Misdaad 1: “ Height= " 22px " >
<td>
><td>
<td>
No>
Yesm>

d>
>
r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_1“) %>' >




DataSourceID= " SqlDataSource4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatus“) %>' >
RepeatDirection= " Horizontal "
SelectedIndex='<%# Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime1“)) %>'> No>Item Value= " 1 " >Yesm>


>

No>Item Value= " 1 " >Yesm>
>


)) %>'> No>Item Value= " 1 " >Yesm>
>

td>


el>

No>Item Value= " 1 " >Yesm>
>

</td>


emplate>


Crime 2
r><td>
d>
Text= " Geprobeerde Misdaad 2: “ Height= " 22px " >
<td>
><td>
<td>
No>Item Value= " 1 " >Yesm>

d>
>
r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_2“) %>'>




DataSourceID= " SqlDataSource4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatusNum_2“) %>' >
RepeatDirection= " Horizontal " SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime2“))%>'> No>Item Value= " 1 " >Yesm>


>
RadioButtonListID= " rblSex2i“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num2“))%>'> No>Item Value= " 1 " >Yesm>
>

RadioButtonListID= " rblRegister2i“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_2 " ))%>'> No>Item Value= " 1 " >Yesm>
>

td>


el>
ButtonList ID= de " rblFelony2i“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_2“))%>'> No>Item Value= " 1 " >Yesm>
>

</td>


emplate>


Crime 3
r><td>
d>
Text= " Geprobeerde Misdaad 3: “ Height= " 22px " >
<td>
><td>
<td>
No>Item Value= " 1 " >Yesm>

d>
>
r>

DataSourceID= " SqlDataSource2“ DataTextField= " LAST“
DataValueField= " LAST“ SelectedValue='<%# bindt („IndexCrimeNum_3“) %>'>




DataSourceID= " SqlDataSource4“ DataTextField= " AdjudicationStatus“
DataValueField= " AdjudicationStatus“
SelectedValue='<%# bindt („AdjudicationStatusNum_3“) %>' >
RepeatDirection= " Horizontal " SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „Attempted_Crime3“))%>'> No>Item Value= " 1 " >Yesm>


>
RadioButtonListID= " rblSex3i“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „SexOffense_Num3“))%>'> No>Item Value= " 1 " >Yesm>
>

RadioButtonListID= " rblRegister3i“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „RegisterableOffenseNum_3 " ))%>'> No>Item Value= " 1 " >Yesm>
>

td>


el>
ButtonList ID= de " rblFelony3i“ runat= " server“ RepeatDirection=Horizontal SelectedIndex='<%#Convert.ToInt32 (DataBinder.Eval (((DataRowView) FormView1.DataItem), „FelonyNum_3“))%>'> No>Item Value= " 1 " >Yesm>
>

</td>


emplate>

tton ID= " btnInsert“ runat= " server“ Text= " Tussenvoegsel“ CommandName= " Tussenvoegsel“/>

Antwoord : Formview - Uitzondering System.NullReference wanneer het gebruiken van FindControlRecursive

Ik zou zeggen het niet mogelijk is. De vraag is gesteld hier vóór, en het eindresultaat was dat de agent DPM in het zelfde bos en het domein van de ADVERTENTIE moet zijn zoals de server DPM.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_24029057.html

Andere oplossingen  
 
programming4us programming4us