Hi All, 

Question #1: 

To add a blank value at the top of a dropdownlist, I am loading data 
into it in my FormView1_DataBound. 

It keeps giving me an error: 
System.ArgumentOutOfRangeException: 'ddlApprovers' has a 
SelectedValue which is invalid because it does not exist in the list 
of items. 
Parameter name: value 

I know the value being returned is definitely Null. Please help. 
Thanks!!! 

Question #2: 
Is there a way to retrieve the field in code in a sqlDataSource? If 
I could do it, then I could write it out and maybe use the following 
line to set the selected value? 
ddlApprovers.Items.FindByText([sqlDatasource2.......?]).Selected = 
True 



    <asp:DropDownList ID="ddlApprovers" runat="server" 
selectedValue='<%# Bind("certby") %>'>   <asp:SqlDataSource 
ID="SqlDataSource2" runat="server"          ConnectionString="<%$ 
ConnectionStrings:aSysConnectionString %>"             
SelectCommand="sp_oneTaskRec" 
SelectCommandType="storedProcedure"              
DeleteCommand="DELETE FROM [tblTasks] WHERE [TaskID] = 
@TaskID"              UpdateCommand="UPDATE [tblTasks] SET 
[updateName] = @updateName, [testNeeded] = @testNeeded, 
[testDuration] = @testDuration, [Result] = @Result, [testPlan] = 
@testPlan, [backoutPlan] = @backoutPlan, [comment] = @comment, 
[opDate] = @opDate, [opTime] = @opTime, [testResultDueDate] = 
@testResultDueDate, [testResultDueTime] = @testResultDueTime, 
[testResultComment] = @testResultComment, [actualTestResultDate] = 
@actualTestResultDate, [actualTestResultTime] = 
@actualTestResultTime, [certBy] = @certBy, [certOn] = @certOn, 
[opID] = @opID WHERE [TaskID] = @TaskID" >             
<DeleteParameters>                 <asp:Parameter Name="TaskID" 
Type="Int32" />             </DeleteParameters>             
<SelectParameters>                 <asp:ControlParameter 
ControlID="GridView1" Name="TaskID" PropertyName="SelectedValue" 
type="Int32"/>             </SelectParameters>             
<UpdateParameters>                 <asp:Parameter Name="updateName" 
Type="String" />                 <asp:Parameter Name="testNeeded" 
Type="Boolean" />                 <asp:Parameter Name="testDuration" 
Type="Int32" />                 <asp:Parameter Name="Result" 
Type="Int32" />                 <asp:Parameter Name="testPlan" 
Type="String" />                 <asp:Parameter Name="backoutPlan" 
Type="String" />                 <asp:Parameter Name="comment" 
Type="String" />                 <asp:Parameter Name="opDate" 
Type="DateTime" />                 <asp:Parameter Name="opTime" 
Type="DateTime" />                 <asp:Parameter 
Name="testResultDueDate" Type="DateTime" />                 
<asp:Parameter Name="testResultDueTime" 
Type="DateTime" />                 <asp:Parameter 
Name="testResultComment" Type="String" />                 
<asp:Parameter Name="actualTestResultDate" 
Type="DateTime" />                 <asp:Parameter 
Name="actualTestResultTime" Type="DateTime" />                 
<asp:Parameter Name="certBy" Type="Int32" 
ConvertEmptyStringToNull="true" />                 <asp:Parameter 
Name="certOn" Type="DateTime" />                 <asp:Parameter 
Name="opID" Type="Int32" />                 <asp:Parameter 
Name="TaskID" Type="Int32" />             
</UpdateParameters>         </asp:SqlDataSource> '-------------------
------  Protected Sub FormView1_DataBound(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles FormView1.DataBound         
GetApproverList()     End Sub     Sub GetApproverList
()          '===== works ======         Dim myconnection As New 
SqlConnection(ConnString)         myconnection.Open()         Dim 
strSQL As String = "SELECT uID, uName FROM tblUsers where 
ApprovalRight = 1 ORDER BY uName"         Dim objCommand As New 
SqlCommand(strSQL, myconnection)          Dim objDataReader As 
SqlDataReader = objCommand.ExecuteReader
(CommandBehavior.CloseConnection)         Response.Write
("hello")         Dim ddlApprovers As 
System.Web.UI.WebControls.DropDownList         ddlApprovers = 
FormView1.FindControl("ddlApprovers")         
ddlApprovers.DataSource = objDataReader         
ddlApprovers.DataTextField = "uName"         
ddlApprovers.DataValueField = "uid"         ddlApprovers.DataBind
()         ddlApprovers.Items.Insert(0, "")          'Response.Write
(Data.Sq.DefaultValue)         'ddlApprovers.SelectedValue 
= "certBy" 'SqlDataSource2.SelectParameters
("certby").DefaultValue         'ddlApprovers.Items.FindByText
("").Selected = True         'Response.Write(strSQL & "<br>" & 
objDataReader.HasRows)          objDataReader.Close()         
objDataReader = Nothing         myconnection.Close()     End Sub  
 
 

 








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNet2/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to