Quantcast
Channel: DataSource Controls - SqlDataSource, ObjectDataSource, etc.
Viewing all articles
Browse latest Browse all 956

SelectParameter in SelectCommand does not always has a valid value

$
0
0

I have a datasource control with a SELECT statement and SelectParameters as follows:

<cc1:PgSqlDataSource 
        ID="dsdocDetalle" 
        runat="server" 
        OldValuesParameterFormatString="Original_{0}" 
        ProviderName="<%$ ConnectionStrings:PgSqlConnection.ProviderName %>" 
        SelectCommand="SELECT 
det_id, det_id_doc, det_tipo_docto, det_cliente, det_archivo_pdf, 
tdc_nombre, cte_nombre
FROM 
documentos_detalle 
INNER JOIN cat_tipos_docto ON tdc_id = det_tipo_docto 
INNER JOIN cat_clientes ON cte_id = det_cliente 
WHERE 
det_id_doc = :prmDocId"><SelectParameters><asp:SessionParameter SessionField="sesDocId" Type="Int32" Name="prmDocId" /></SelectParameters></cc1:PgSqlDataSource>

It is actually working fine but I would like to include 1 additional SelectParameter based on 1 control. I know that I must add a line like:

<asp:ControlParameter ControlID="cboControl" PropertyName="Value" Name="ControlName" />

My issue is that this control does not have a value because the user has the choice of selecting a value or not. It is a ComboBox and the user can decide to leave it blank. In this case, the SelectedIndex property would be -1 and it should no be considered as part of the condition. One solution is to write this code in C# but I want to know is there is a workaround so I can continue using the SELECT command and its parameters in the DataSource control.

I will very much appreciate your feedback.

Respectfully,
Jorge Maldonado


Viewing all articles
Browse latest Browse all 956

Trending Articles