This topic is locked

Can I use an Optional Dropdown List from a table

5/23/2007 8:31:10 AM
ASPRunner.NET General questions
S
shelbig author

In my main table I have quite a few drop-down lists created by the Lookup Wizard.

Since some of these are optional the data in the pre-existing main table has a NULL entry for the key to the lookup table.
This appears to cause an error when I try to EDIT or View that table:
[indent]'fieldname' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value[/indent]
What can I do about this please?

Eugene 5/23/2007

NULL entry hasn't to be a reason for this error. It can happens only if in main table there are values, that doesn't exist in lookup table (except NULL value).
Could you please send me your project (including project file, output directory and database backup) on support@xlinesoft.com? I will investigate it on my box.

S
shelbig author 5/23/2007

[indent]> NULL entry hasn't to be a reason for this error. It can happens only if in main table there are values, that doesn't exist in lookup table (except NULL value).[/indent]


Thanks for your reply.

Your point may be valid but even if there are values in the main tables that do not exists in the Lookup table, is this a valid reason to stop the application with an error? Yes the data may be invalid but aborting the application prevents a user from correcting it.
Could this not be made optional somehow, with a warning rather than an error? Or since the key would not match the lookup file, simply not select any value in the Drop Down list, and then let the validation process force the user to correct the data error?
Also do you have any news on the next major release of ASPRunner.net?
Thanks

Eugene 5/24/2007

try to use unbound DropDownList.

change DropDownList properties on .aspx page

old code
<asp:DropDownList id="fldFileName"

DataTextField="TextField" DataValueField="ValueField" SelectedValue='<%#Bind("FileName")%>'

DataSource=<%# func.GetSqlDataSource("sql select") %>

AppendDataBoundItems="True" runat="server" >
new code

<asp:DropDownList id="fldFileName"

DataTextField="TextField" DataValueField="ValueField"

AppendDataBoundItems="True" runat="server" >
and add this code to .vb file:

in Sub _DataBound
func.LoadDataToLookUp(CType(TableDetailsView.FindControl("fldFileName"), DropDownList), "sql select", DataBinder.Eval(OrdersDetailsView.DataItem, "FileName").ToString())
and in Sub _ItemUpdating
e.NewValues("FileName") = CType(Table[/iDetailsView.FindControl("[i]fldFileName"), DropDownList).SelectedValue

R
rob 6/26/2007

try to use unbound DropDownList.

change DropDownList properties on .aspx page

old code
<asp:DropDownList id="fldFileName"

DataTextField="TextField" DataValueField="ValueField" SelectedValue='<%#Bind("FileName")%>'

DataSource=<%# func.GetSqlDataSource("sql select") %>

AppendDataBoundItems="True" runat="server" >
new code

<asp:DropDownList id="fldFileName"

DataTextField="TextField" DataValueField="ValueField"

AppendDataBoundItems="True" runat="server" >
and add this code to .vb file:

in Sub _DataBound
func.LoadDataToLookUp(CType(TableDetailsView.FindControl("fldFileName"), DropDownList), "sql select", DataBinder.Eval(OrdersDetailsView.DataItem, "FileName").ToString())
and in Sub _ItemUpdating
e.NewValues("FileName") = CType(Table[/iDetailsView.FindControl("[i]fldFileName"), DropDownList).SelectedValue


I have the same issue, this code does work on the edit. But the other issue i have is that the field that is set up as the lookup wizard does not show up on the list page. Was this issue resolved too?
Thanks!

R
rob 6/27/2007



I have the same issue, this code does work on the edit. But the other issue i have is that the field that is set up as the lookup wizard does not show up on the list page. Was this issue resolved too?
Thanks!


Fixed. Thanks..