locked
Defalut Value in select parameter-Sqldatasource RRS feed

  • Question

  • User-1736042568 posted

    Hi all, I have one question about Default Value in <select parameter> in sqldatasource. As you can see after <SelectParameters> line ,<asp:Parameter DefaultValue="NOT APPROVE" Name="DeptHeadApproval" />. How I want to set DefaultValue from 'NOT APPROVE' to other than 'NOT APPROVE'.In sql we always write DefaultValue!="NOT APPROVE". How? Anyone can help me?

    2. One more question, For example in table DeptHeadApproval, we have value(NOT APPROVE, APPROVE, REJECTED, KIV), so, how i want to set parameter to APPROVE 'OR' REJECTED 'OR' KIV??? As I now we can set one value only in Default Value.

    This is my sqldatasoure:

    <asp:SqlDataSource ID="AllPRDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SecurityTutorialsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:SecurityTutorialsConnectionString.ProviderName %>" 
            
            
            SelectCommand="SELECT UserId, PrId, DateRequest, Div, Dept, Sect, SSect, JobTitle, JobGrade, MinQualification, FieldStudy, SpecificSkills, AdditionalSkill, PrefYearsExp, PrefDateJoin, Others, Reason, NoOfHeadcount, Status, KeyinDate, DeptHeadApproval, DeptHeadApprovalDate, DIVHeadApproval, DIVHeadApprovalDate, GenAdminApproval, GenAdminApprovalDate, PresidentApproval, PresidentApprovalDate, HRStaffingApproval, HRStaffingApprovalDate, PrType, PrNo FROM personnelrequisition WHERE (DeptHeadApproval = @DeptHeadApproval) AND (Status = @Status) AND (DIVHeadApproval = @DIVHeadApproval) AND (GenAdminApproval = @GenAdminApproval) AND (PresidentApproval = @PresidentApproval) AND (HRStaffingApproval = @HRStaffingApproval) ORDER BY DateRequest DESC">
            <SelectParameters>
                <asp:Parameter DefaultValue="NOT APPROVE" Name="DeptHeadApproval" />
                <asp:Parameter DefaultValue="PENDING" Name="Status" />
                <asp:Parameter DefaultValue="NOT APPROVE" Name="DIVHeadApproval" />
                <asp:Parameter DefaultValue="NOT APPROVE" Name="GenAdminApproval" />
                <asp:Parameter DefaultValue="NOT APPROVE" Name="PresidentApproval" />
                <asp:Parameter DefaultValue="NOT APPROVE" Name="HRStaffingApproval" />
            </SelectParameters>
        </asp:SqlDataSource>
    Wednesday, October 5, 2011 11:52 PM

Answers

  • User82239924 posted

    My idea is,

    Rewrite a portion select command

    ........... FROM personnelrequisition WHERE (DeptHeadApproval <> @DeptHeadApproval)........

    as follows,

    SelectCommand="SELECT UserId, PrId, DateRequest, Div, Dept, Sect, SSect, JobTitle, JobGrade, MinQualification, 
    FieldStudy, SpecificSkills, AdditionalSkill, PrefYearsExp, PrefDateJoin, Others, Reason, NoOfHeadcount, Status,
    KeyinDate, DeptHeadApproval, DeptHeadApprovalDate, DIVHeadApproval, DIVHeadApprovalDate, GenAdminApproval,
    GenAdminApprovalDate, PresidentApproval, PresidentApprovalDate, HRStaffingApproval, HRStaffingApprovalDate, PrType,
    PrNo FROM personnelrequisition
    WHERE (DeptHeadApproval <> @DeptHeadApproval) AND (Status = @Status) AND (DIVHeadApproval = @DIVHeadApproval) AND
    (GenAdminApproval = @GenAdminApproval) AND (PresidentApproval = @PresidentApproval) AND (HRStaffingApproval = @HRStaffingApproval)
    ORDER BY DateRequest DESC"
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 6, 2011 12:27 AM