Please Help me- Returning DataSet from a Web Service

Discussion in 'ASP .Net Web Controls' started by Sumaira Ahmad, Nov 1, 2004.

  1. Hi All

    My Web Service is returning a DataSet. I realized that we cannot
    return a DataReader.. Normally we can use a DataReader( when not
    using Web services) and access it as below to assign values of columns
    of returned rows to Labels in the client aplication such as:

    while (dtrJobDetails.Read())
    {
    l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
    }
    where dtrJobDetails is a DataReader.

    But now I am forced to return back a DataSet.. Is there anyway of
    showing the individual column values returned from a DataSet in
    individual labels like we do in a DataReader as above... I dont want
    to show it in a DataGrid or a DataList...

    Please help me.. I have been trying to figure this out since two
    days..

    Any help will be highly appreciated...
    Thanks,
    Sumaira
     
    Sumaira Ahmad, Nov 1, 2004
    #1
    1. Advertising

  2. What about dropping a placeholder control onto the page and then loop
    through the datarows of the dataset, adding the labels dynamically?

    I've included some VB code below that might give you the idea.

    Let us know if it helps?

    Ken
    Microsoft MVP [ASP.NET]


    <form runat=server>
    <asp:placeHolder id="PlaceHolder1" runat="server">
    </asp:placeHolder></FORM>



    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim l_shortjobdesc As Label
    Dim ltBR As Literal
    Dim ds As New DataSet
    ds = CreateDataSource()
    Dim dr As DataRow
    For Each dr In ds.Tables(0).Rows
    l_shortjobdesc = New Label
    l_shortjobdesc.Text = dr.Item("IntegerValue").ToString
    ltBR = New Literal
    ltBR.Text = "<br>"
    PlaceHolder1.Controls.Add(l_shortjobdesc)
    PlaceHolder1.Controls.Add(ltBR)
    Next
    End Sub
    Function CreateDataSource() As DataSet
    Dim ds As New DataSet
    Dim dt As New DataTable
    Dim dr As DataRow
    dt.Columns.Add(New DataColumn _
    ("IntegerValue", GetType(Int32)))
    dt.Columns.Add(New DataColumn _
    ("StringValue", GetType(String)))
    dt.Columns.Add(New DataColumn _
    ("CurrencyValue", GetType(Double)))
    dt.Columns.Add(New DataColumn _
    ("Boolean", GetType(Boolean)))
    Dim i As Integer
    For i = 0 To 8
    dr = dt.NewRow()
    dr(0) = i
    dr(1) = "Item " + i.ToString()
    dr(2) = 1.23 * (i + 1)
    dr(3) = (i = 4)
    dt.Rows.Add(dr)
    Next i
    ds.Tables.Add(dt)
    Return ds
    End Function 'CreateDataSource


    "Sumaira Ahmad" <> wrote in message
    news:...
    > Hi All
    >
    > My Web Service is returning a DataSet. I realized that we cannot
    > return a DataReader.. Normally we can use a DataReader( when not
    > using Web services) and access it as below to assign values of columns
    > of returned rows to Labels in the client aplication such as:
    >
    > while (dtrJobDetails.Read())
    > {
    > l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
    > }
    > where dtrJobDetails is a DataReader.
    >
    > But now I am forced to return back a DataSet.. Is there anyway of
    > showing the individual column values returned from a DataSet in
    > individual labels like we do in a DataReader as above... I dont want
    > to show it in a DataGrid or a DataList...
    >
    > Please help me.. I have been trying to figure this out since two
    > days..
    >
    > Any help will be highly appreciated...
    > Thanks,
    > Sumaira
     
    Ken Cox [Microsoft MVP], Nov 3, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sumaira Ahmad
    Replies:
    2
    Views:
    416
    bruce barker
    Nov 2, 2004
  2. Sumaira Ahmad

    Please Help me- Returning DataSet from a Web Service

    Sumaira Ahmad, Nov 1, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    114
    Sumaira Ahmad
    Nov 1, 2004
  3. Curly
    Replies:
    0
    Views:
    199
    Curly
    Aug 19, 2003
  4. Ketchup
    Replies:
    1
    Views:
    249
    Jan Tielens
    May 25, 2004
  5. Sumaira Ahmad

    Please Help me- Returning DataSet from a Web Service

    Sumaira Ahmad, Nov 1, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    110
Loading...

Share This Page