I have a dataset that reads in an xml WebResponse and i then extract and merge tables from this dataset how can I add 7 hard coded labels to the merged table to display in datagrid, the labels with always be the same values and the order will always be the same.
I guess to make it easy I want to add 7 row headers to the table? To be displayed with a datagrid.
What I Tried
WebRequest req = WebRequest.Create(m_uri);
WebResponse rsp;
req.Method = "POST";
req.ContentType = "text/xml";
StreamWriter writer = new StreamWriter(req.GetRequestStream());
writer.WriteLine(buildXml().ToString());
writer.Close();
rsp = req.GetResponse();
//Get the Posted Data
StreamReader reader = new StreamReader(rsp.GetResponseStream());
string rawXml = reader.ReadToEnd();
XmlDocument xml = new XmlDocument();
xml.LoadXml(rawXml);
//Use XPath to Navigate the Document
int status = Convert.ToInt32(xml.SelectSingleNode(@"/RatingServiceSelectionResponse/Response/ResponseStatusCode").InnerText);
if (status == 1)
{
StringReader srxml = new StringReader(rawXml);
DataSet dsAuthors = new DataSet("RatedShipment");
dsAuthors.ReadXml(srxml);
dsAuthors.EnforceConstraints = false;
DataTable Shipment = dsAuthors.Tables[2];
DataTable TotalCharges = dsAuthors.Tables[8];
DataTable table = new DataTable("UPS Service");
Shipment.Merge(TotalCharges);
Shipment.Columns.Remove("RatedShipmentWarning");
Shipment.Columns.Remove("CurrencyCode");
Shipment.Rows.RemoveAt(7);
DataColumn UPSService = new DataColumn();
UPSService.DataType = typeof(string);
UPSService.ColumnName = "UPS Service";
Shipment.Columns.Add(UPSService);
Shipment.Rows[0].Cells[0].Value = "UPS Ground";
Shipment.Rows[1].Cells[0].Value = "UPS Three Day";
Shipment.Rows[2].Cells[0].Value = "UPS Second Day A.M.";
Shipment.Rows[3].Cells[0].Value = "UPS Second Day";
Shipment.Rows[6].Cells[0].Value = "UPS Next Day Air Saver";
Shipment.Rows[4].Cells[0].Value = "UPS Next Day Air Early A.M.";
Shipment.Rows[5].Cells[0].Value = "UPS Next Day Air";
dataGridView1.DataSource = Shipment;
}
else
{
MessageBox.Show("Unable To Process: Please Check All Fields Are Entered");
}
But the Cells After the rows is not correct.
Then you have to do this: