Wednesday, December 24, 2014

sqldatasource select with argument then bind to dataview


 <asp:SqlDataSource ID="srcPaperTypes" runat="server" ConnectionString="<%$ ConnectionStrings:ODAC_ConnString %>" ProviderName="<%$ ConnectionStrings:ODAC_ConnString.ProviderName %>"
                     SelectCommand="SELECT        DOC_SER, DOC_NAME
FROM            SHR.DOCS_SCAN
WHERE        (SYSNO = 7)
AND DOC_SER=:DOC_SER">
                    <SelectParameters>
                        <asp:Parameter Name="DOC_SER" />
                    </SelectParameters>
                </asp:SqlDataSource>






--------------------------------------------------------------------
 srcPaperTypes.SelectParameters.Clear();
        srcPaperTypes.SelectParameters.Add(new Parameter("DOC_SER",TypeCode.String, papertype.ToString()));
        DataSourceSelectArguments args = new DataSourceSelectArguments();
        DataView DV = new DataView();
        DV = (DataView)srcPaperTypes.Select(DataSourceSelectArguments.Empty);
        if(DV != null)
        result = DV.Table.Rows[0]["DOC_NAME"].ToString();

No comments:

Post a Comment