Updates query and Dropdowns in a formview

G

Guest

I have a form that calls a stored procedure to perform updates to a table in
sqlserver.

When I have a dropdown with a list item value of nothing, the formview
control passes up the wrong value to the stored procedure. In some cases
this will be the primary key for my record and in a different dropdown on the
same page I may get the "*" symbol. I'm not sure what the problem is though.

NOte: I did have an issue setting up the formview control to use the stored
procedure type. I couldn't get it to work. (If you have the syntax that
would be greatly appreciated). If you set the UpdateommandType to Stored
Procedure, the "Update Query Command and Parameter Editor->QueryBuilder
Button" isn't smart enough to know that I don't want a select query. So, I
used the text type and used the following syntax "exec [myupdateproc]
@param1,@param2, @paramN.

I don't know if the two issues are related.

ANyway, in cases where my record has a null in the dropdown field [its not a
required field] I use the following code to select the null record for the
dropdown.
<asp:DropDownList ID="DDayoff" runat="server"
SelectedValue='<%#Bind("Dayoff") %>'>
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem>Mon</asp:ListItem>
<asp:ListItem>Tues</asp:ListItem>
<asp:ListItem>Wed</asp:ListItem>
<asp:ListItem>Thur</asp:ListItem>
<asp:ListItem>Fri</asp:ListItem>

</asp:DropDownList>

Am I doing something wrong here? What is the proper way to do this in a
formview control?
 
G

Guest

Just wanted to update: I added the UpdateCommandType="Stored Procedure" And
changed the syntax of the update statement accordingly and this did not fix
the problem.

Also, I've noticed that the same thing happens for any bound control in the
editItemTemplate. If I leave any field blank, it will pass the primary key
in place of the null value.
 
G

Guest

I found a solution and wanted to post it for anyone having the same problem.

In the Command and Property Editor, you have to set the
ConvertEmptyStringToNull parameter to false. If you leave it true, something
gets messed up between the formview and the sqldatasource and it assigns the
value as your primary key.
 
G

Guest

I feel your pain. This was my whole day today. I'm just trying to access the
properties of ANY web controls within a FormView control.

I have a FormView control with a dropdownlist control bound to a lookup
table. I want to add "Select..." as the first option in the dropdown. Piece
of cake outside a FormView, but completely stumping me within.

Its KILLING ME!!!!!
 
G

Guest

I have to say I'm beginning to hate some of these new controls. I keep
running into little things that you think should work a certain way but they
don't.

Today it was the Gridview in Asp.net. That sucker doesn't use the rowstyle.
I set the borderstyle and border color and nothing... What the heck.

And am I the only one that has noticed the buggy Properties pane? There has
got to be a bug in that thing. It is not tracking focus correctly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top