Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Am not able to bind the dataset to the gridview.

below are my aspx and .vb code
ASP.NET
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="BVAL_Prices.aspx.vb" Inherits="BVAL_Prices" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link href="../../styles/quicksite.css" type="text/css" rel="stylesheet">
<link href="../../styles/chkBoxScroll.css" rel="stylesheet" type="text/css" />
<script src="../scripts/rwhitespace.js" type ="text/jscript" ></script>
</head>
<BODY id=RWhitespaceBody onresize=rwhitespace_onresize()  önload=rwhitespace_onload() style="padding-right:0;">

<div class="RightPannel" id="RightPannel">
<div class="RightHeader" id="RightHeader">BVAL Prices</div>
<div class="RightPannelBody" id="RightPannelBody">
    <table cellpadding="5" cellspacing="0" border="0" bordercolor="black" width="100%><br" mode="hold" />        <tr>
            <td style="width: 2%">
            </td>
            <td style="width: 96%" valign="top">
            <!-- content goes here-->
           <form id="form1"  runat="server" >

              <div style="width: 100%;height:40px; background-color:white; border:solid 1 #808080; padding: 0 0 2 0;">
              <div class="RightHeader">

                </div>
                <div style="padding: 2 5 2 5;">
                <table id="Table1" width="100%" cellpadding="0" cellspacing="0"  runat="server">
            <tr>
            <td style="width:10%" valign="Top">
                  <asp:Button ID="btnAddSub" runat="server" Text="Add/Subtract Columns"
                  OnClientClick="ShowDiv(); return true" />
            </td>
            <td style="width:10%" valign="top">
            <div id ="dv"  runat="server" visible="false" style="overflow-Y: scroll; height: 100px; background-color: #FFFFFF;  width: 200px;">
             <asp:CheckBoxList ID = "chkColumns" runat="server" AutoPostBack="true">
             </td></tr></div>

                </div></td>
                 <td style="width:20%" valign="top">
                            <asp:Button ID="btnExportToExcel" runat="server" Text="Export To Excel" />&nbsp;
                 </td>

            </tr>
             
        <table width="98%" border="0" cellspacing="0" cellpadding="0">

            <tr> <td colspan="2">
               <asp:GridView ID="BVAL_Prices" runat="server" Visible="true"
                        AutoGenerateColumns="False"   DataKeyNames="MR_SEC_ID"
                        BorderColor="#E7E7FF" BorderWidth="0px"
                        CellPadding="3" GridLines="Vertical" Width="98%">

                        <columns>
                           <asp:BoundField HeaderText="MR SEC ID" DataField="MR_SEC_ID" Visible ="true"/>
                          <asp:BoundField HeaderText="STATE STREET CUSIP" DataField="STATE_STREET_CUSIP" Visible ="true"/>
                           <asp:BoundField HeaderText="BOND CUSIP" DataField="BOND_CUSIP" Visible ="true"/>
                            <asp:BoundField HeaderText="BLOOMBERG SECURITY ID" DataField="BLOOMBERG_SECURITY_ID" SortExpression="BLOOMBERG_SECURITY_ID" Visible ="true"/>
                            <asp:BoundField HeaderText="BB UNIQUE" DataField="BB_UNIQUE"  SortExpression="BB_UNIQUE" Visible ="true"/>
                            <asp:BoundField HeaderText="Prices"  DataField="Prices" SortExpression="Prices" Visible ="true"/>
                        </columns>
                        <HeaderStyle Font-Size="10px" BackColor="#dbd8d1" />
                        <alternatingrowstyle backcolor="#E7E7FF" />
                    

            </td>
        </tr>
        </table>
        <br />

                <!-- Block content goes here-->
                </div>
            </div>
            <br />

                <asp:SqlDataSource ID="models_info" runat="server"
            ConnectionString="<%$ ConnectionStrings:oramrp1_conn %>"
            ProviderName="<%$ ConnectionStrings:oramrp1_conn.ProviderName %>"
            SelectCommand="
select model_code,model_nme,comments_txt,Comments_Id
from lam_pricing.model
            ">

        

            </form>
            
            <td style="width: 2%">
            </td>    
</BODY></HTML>


Below is my vb code
VB
Imports System.Timers
Imports System.Data
Imports System.Windows.Forms
Imports IFC.Applications.PricingModel
Imports PricingDatabase
Imports PerSecurityWSDL
Imports System.Security.Cryptography.X509Certificates
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web
Imports System.Data.OracleClient


Partial Class BVAL_Prices
    Inherits System.Web.UI.Page

    Private Shared aTimer As System.Timers.Timer
    Dim sbmtGetDataReq As PerSecurityWSDL.SubmitGetDataRequest = New PerSecurityWSDL.SubmitGetDataRequest()
    Dim sbmtGetDataRes As PerSecurityWSDL.SubmitGetDataResponse = New PerSecurityWSDL.SubmitGetDataResponse()
    Dim retGetDataRes As PerSecurityWSDL.RetrieveGetDataResponse = New PerSecurityWSDL.RetrieveGetDataResponse()
    Dim retGetDataReq As PerSecurityWSDL.RetrieveGetDataRequest = New PerSecurityWSDL.RetrieveGetDataRequest()
    Dim ps As PerSecurityWSDL.PerSecurityWS = New PerSecurityWSDL.PerSecurityWS()

    Dim getDataHeaders As PerSecurityWSDL.GetDataHeaders = New PerSecurityWSDL.GetDataHeaders()

    Public MaxHeight As Integer = 300
    ''' <summary>
    ''' The width of the popup
    ''' </summary>
    Public Width As Integer = 200



    Dim objDao As New DAO

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
           
            If Not Page.IsPostBack Then

                bindBVALPrices()


            End If


        Catch ex As Exception

        End Try
    End Sub

    Public Sub bindBVALPrices()
        Try
            

            Dim certificatePath As String = System.Configuration.ConfigurationManager.AppSettings("BloombergCertificatePath")
            Dim Password As String = System.Configuration.ConfigurationManager.AppSettings("BBPassword")

            Dim clientCert As New X509Certificate2(certificatePath, Password)

            Dim strsqlBB As String = "SELECT PSBM.MR_SEC_ID,PSBM.SECURITY_ID,  PSBM.BB_UNIQUE FROM LAM_PRICING.PRICING_SECURITY_BB_MAPPING PSBM" & _
                                          " WHERE PSBM.MR_SEC_ID IN (SELECT PSM.MR_SEC_ID FROM LAM_PRICING.PRICING_SECURITY_MASTER PSM" & _
                                            " WHERE PSM.ACTIVE_IND = 'Y' AND PSM.ASSET_TYPE_CODE = 'BOND')"


            Dim strconnection As String = ConfigurationManager.ConnectionStrings("oramrp1_conn").ConnectionString

            Dim connection As New OracleConnection(strconnection)

            Dim cmd As New OracleCommand(strsqlBB, connection)
            Dim sqlDa As New OracleDataAdapter(cmd)
            Dim dsBB As DataSet = New DataSet
            sqlDa.Fill(dsBB)
            'test.DataSource = dsBB
            'test.DataBind()

            Dim icount As Integer = 0
            icount = dsBB.Tables(0).Rows.Count - 1
            Dim strbb(icount) As String
            'SendLotus()

            ps.ClientCertificates.Add(clientCert)
           
            Dim instrumentBB(icount) As PerSecurityWSDL.Instrument
            Dim insBB As PerSecurityWSDL.Instruments = New PerSecurityWSDL.Instruments
            ' Dim fieldset As PerSecurityWSDL.BvalFieldSet = New PerSecurityWSDL.BvalFieldSet()


            If (dsBB.Tables(0) Is Nothing) Then
                'MessageBox.Show("No BVAL Prices")
            Else


                For iDsBBCount As Integer = 0 To dsBB.Tables(0).Rows.Count - 1
                    instrumentBB(iDsBBCount) = New Instrument
                    instrumentBB(iDsBBCount).id = dsBB.Tables(0).Rows(iDsBBCount)("BB_UNIQUE").ToString
                    instrumentBB(iDsBBCount).type = InstrumentType.BB_UNIQUE
                    instrumentBB(iDsBBCount).typeSpecified = True
                Next


            End If

            getDataHeaders.secmaster = True
            getDataHeaders.secmasterSpecified = True
            getDataHeaders.closingvalues = True
            getDataHeaders.closingvaluesSpecified = True
            getDataHeaders.derived = True
            getDataHeaders.derivedSpecified = True

            insBB.instrument = instrumentBB

            sbmtGetDataReq.headers = getDataHeaders
            sbmtGetDataReq.instruments = insBB
            sbmtGetDataReq.fields = New String() {"PX_LAST", "ID_BB_UNIQUE"}

            Try
                sbmtGetDataRes = ps.submitGetDataRequest(sbmtGetDataReq)
                retGetDataReq.responseId = sbmtGetDataRes.responseId
                retGetDataRes = ps.retrieveGetDataResponse(retGetDataReq)
                If retGetDataRes.statusCode.code = 100 Then
                    aTimer = New System.Timers.Timer()
                    ' Hook up the Elapsed event for the timer. 
                    AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
                    ' Set the Interval to 5 mins (300000 milliseconds).
                    aTimer.Interval = 300000
                    aTimer.Enabled = True
                End If
            Catch ex As Exception
            End Try
        Catch ex As Exception

        End Try

    End Sub
    Public Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs)

        aTimer.Enabled = False
        aTimer.Stop()
        GetPrices()

    End Sub

    Public Sub GetPrices()

        Dim strsqlBB As String = "SELECT PSBM.MR_SEC_ID, PSBM.STATE_STREET_CUSIP, PSBM.BOND_CUSIP, PSBM.BLOOMBERG_SECURITY_ID,  PSBM.BB_UNIQUE FROM LAM_PRICING.PRICING_SECURITY_BB_MAPPING PSBM " & _
                                          " WHERE PSBM.MR_SEC_ID IN (SELECT PSM.MR_SEC_ID FROM LAM_PRICING.PRICING_SECURITY_MASTER PSM" & _
                                            " WHERE PSM.ACTIVE_IND = 'Y' AND PSM.ASSET_TYPE_CODE = 'BOND')"

        Dim strconnection As String = ConfigurationManager.ConnectionStrings("oramrp1_conn").ConnectionString

        Dim connection As New OracleConnection(strconnection)

        Dim cmd As New OracleCommand(strsqlBB, connection)
        Dim sqlDa As New OracleDataAdapter(cmd)
        Dim dsBB As DataSet = New DataSet
        sqlDa.Fill(dsBB)
        Dim drBval As DataRow
        Dim dcBVal As DataColumn
        dcBVal = New DataColumn()
        Dim dtBval As DataTable = GetTable()
        Dim dsBval As DataSet = New DataSet
        retGetDataRes = ps.retrieveGetDataResponse(retGetDataReq)
        For Each dr As DataRow In dsBB.Tables(0).Rows

            For Each inst As InstrumentData In retGetDataRes.instrumentDatas
                If dr.Item("BB_UNIQUE").ToString = inst.instrument.id.ToString Then
                    drBval = dtBval.NewRow()
                    drBval.Item("MR_SEC_ID") = dr.Item("MR_SEC_ID").ToString
                    drBval.Item("STATE_STREET_CUSIP") = dr.Item("STATE_STREET_CUSIP").ToString
                    drBval.Item("BOND_CUSIP") = dr.Item("BOND_CUSIP").ToString
                    drBval.Item("BLOOMBERG_SECURITY_ID") = dr.Item("BLOOMBERG_SECURITY_ID").ToString
                    drBval.Item("BB_UNIQUE") = dr.Item("BB_UNIQUE").ToString
                    drBval.Item("Prices") = inst.data(0).value.ToString
                    dtBval.Rows.Add(drBval)
                End If

            Next


        Next
        dsBval.Tables.Add(dtBval)
        BVAL_Prices.DataSource = dsBval
        BVAL_Prices.DataBind()
        BVAL_Prices.Visible = True

    End Sub
    Public Function GetTable() As DataTable

        Dim dtTable As DataTable
        dtTable = New DataTable

        dtTable.Columns.Add("MR_SEC_ID", GetType(String))
        dtTable.Columns.Add("STATE_STREET_CUSIP", GetType(String))
        dtTable.Columns.Add("BOND_CUSIP", GetType(String))
        dtTable.Columns.Add("BLOOMBERG_SECURITY_ID", GetType(String))
        dtTable.Columns.Add("BB_UNIQUE", GetType(String))
        dtTable.Columns.Add("Prices", GetType(String))

        Return dtTable

    End Function
End Class
Posted
v2
Comments
Nirav Prabtani 4-Jul-13 8:32am    
Pleae Repost your question net and clean.....:)
bbirajdar 5-Jul-13 5:41am    
remove this code -BVAL_Prices.Visible = True

You should either bind a datatable to a Gridview or when you bind a dataset, then you should tell the Gridview which datatable it should be bound to....

C#
DataGridView1.AutoGenerateColumns = True;
DataGridView1.DataSource = ds; // dataset
DataGridView1.DataMember = "TableName"; 
 
Share this answer
 
Comments
komaliks 5-Jul-13 5:06am    
I tried giving the datatable name also.. but even that didnt work for me
The timer was having a prob. Instead of timer I used thread.

System.Threading.Thread.Sleep(300000)

This worked.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900