Consuming webservice, change header text

Jul 12 2007 6:09 AM

Hi,

 

I understand that can be done through the aspx file, but my datasource generates the detailsview at runtime so i do not know what the headers are till it is loaded onto the detailsview. Im using a webservice to read the data which come in XML format. So what is happening is that the xml tags become the headers of the details view which are not very appropriate. I would like to change the header and order the columns of the the detailsview (in this case the columns become the rows in the detailsview control) in a way i would like it.

 

Im using an arraylist to enumrate the data returned by the method.

If you would like to try to consume and add a reference to the webservice you could you it at this url: http://www.resdirect.co.uk/webservices/bookinginfo.asmx

Booking Reference: IRB_0705001484_1

Userid: IVAN

 

 

 

here is the code:

 

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Xml;

using System.Collections;

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

 

BookingRef.Bookinginfo bi = new BookingRef.Bookinginfo();

if ((TextBox1.Text.ToString() != null) && (TextBox2.Text.ToString() != null))

{

 

BookingRef.Booking b = new BookingRef.Booking();

b = bi.GetBooking((TextBox1.Text).ToString(), (TextBox2.Text).ToString());

ArrayList al = new ArrayList();

al.Add(b);

DetailsView1.DataSource = al;

DetailsView1.DataBind();

 

 

 

}

else

{

//Label3.Text = "please enter proper data";

}

}

}

 

aspx file:

<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="Bookinginfoclient.aspx.cs" Inherits="_Default" %>

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<br />

<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />&nbsp;<br />

&nbsp;

&nbsp;&nbsp;

<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>&nbsp;

<asp:DetailsView ID="DetailsView1" runat="server" BackColor="White" BorderColor="#E7E7FF"

BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" Height="50px"

Width="80%">

<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />

<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />

<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />

<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />

<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />

<AlternatingRowStyle BackColor="#F7F7F7" />

</asp:DetailsView>

</div>

&nbsp;

</form>

</body>

</html>

P.S: I am trying to reorder the (heading) columns of the Detailsview header text and also give my own headings in the header text.