i am trying to load this xml file into the dropdownlist:
http://sites.google.com/site/shadchanproject/Home/lots1.xml
i want to only load the a7190, a7193 etc... (there are only three of them i believe)
please help!
i am doing this in asp.net
Hmm, I'm having issues downloading the file.
But in general, if you can download the XML file and create an XSD file based off this (there are several XSD generators out there), you can then create a DataSet object that will read the XML data into a DataTable.
From there, you can create a DataView, filter out the other items so that only the desired elements remain, and bind the DataView to the drop down list.
EDIT: Well, I looked and its simpler than that. You should be able to read the XML file straight in. You won't have a strongly typed table, but you can do this:
Dim dsStuff As New DataSet()
dsStuff.ReadXml("PathToFile")
Dim dvStuff As New DataView(dsStuff.Tables(0))
dvStuff.Sort = "Name = 'FilteredName'"
ddlStuff.DataSource = dvStuff
ddlStuff.DataTextField = "Name"
ddlStuff.DataValueField = "ID"
ddlStuff.DataBind()
Adjust the filter criteria accordingly.
Related
I'm having some trouble with binding a DevExpress XtraReport subreport's datasource to it's containing report's datasource. The datasource is an object collection.
If I create a basic reports with sub detail sections all is well.
For example, the object collection is a list of companies. Each company has a list of addresses and a list of contacts. What I am attempting is to create a report with two subreports side-by-side for each (detail) company.
From several web articles, I thought this approach seemed like it would work:
report.ContactSubreport.ReportSource.DataSource = report.Datasource
which I call from a script using the subreport's BeforePrint event.
I also tried setting the datamember to the name of the sub collection:
report.ContactSubreport.ReportSource.DataMember = "Contacts"
Any help or suggestions would be greatly appreciated. Thanks!
From what I gather, you need to display only child collections' records that belong to the current master record.
In this case, it's better to handle the BeforePrint event of those XRSubreports and call there the XtraReport.GetCurrentRow method for a master report. This method call will return a master record (i.e., an instance of the "Company" object). This will allow you to pass the "Company.Addresses" list to the first subreport and the "Company.Contacts" list to the second one. Thus, the details that only correspond to each "Company" will be printed in both subreports.
I accomplish XtraSubReport dynamic or runtime data binding by doing Something like this and it WORKS perfectly
(VB.NET but can easily be implemented in C#)
NOTE:
The BandKind.Detail parameter below means the subreport was placed in the Detail Band. If not then specify the band of the main report where you placed the subreport in (eg. PageHeader, ReportHeader, PageFooter, etc)
The "XrSubreportInvoiceBank" is the name of the subReport that you created in the main report. You will need to change it to the name of the subreport in your main report
Dim MyDocument As New XtraReportInvoiceHardcopy
Dim BankSubreport As XRSubreport = CType(MyDocument.Bands(BandKind.Detail).FindControl("XrSubreportInvoiceBank", True), XRSubreport)
Dim BankAccount As DataTable = New DataTable 'You can put your Data in here
BankSubreport.ReportSource.DataSource = BankAccount
BankSubreport.Visible = True
I have a asp.net web page that has various pieces of data on it. One of those is a standard html table. 10 columns by 5 rows. I want to place a link below the table that allows the user to click on it and it will export the data from the table into an excel sheet.
Can anyone help?
If you are wanting to export the data i am presuming that the data is dynamic, from a database? On that assumption why not display the data in either a GridView or an ASP table? This way you will be better able to export the data.
If you are dynamically creating the table from code then i guess thats different, but you havent stated how your generating the page.
Exporting Controls to excel: Just change Gridview1 to the id of the control you want to export. Either your ASP table or your gridview ID.
Dim sw As New StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
Dim frm As HtmlForm = New HtmlForm()
Page.Response.AddHeader("content-disposition", "attachment;filename=ExportFromWebPage.xls")
Page.Response.ContentType = "application/vnd.ms-excel"
Page.Response.Charset = ""
Page.EnableViewState = False
frm.Attributes("runat") = "server"
Controls.Add(frm)
frm.Controls.Add(GridView1)
frm.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()
-Edit. Ive shown my naivety here and just assumed this wouldn't work with a native html table. I thought id try it and it actually will work. Just run your table at server and give it an ID then replace gridview1 with the id you've given your HTML table.
im just going to put some articles you can use or other answers but googling html table to excel you can find some answers.
html table to excel using jquery
How to export html table to excel using javascript
what is the easy way of showing xml data in aspx in some sort of data container?
in fx a gridview - note that the xml is in a tree structure
<element1>
<element2>
<element3>
<element4>
......
</element1>
and i also have a schema that defines the xml
System.Data.DataSet has a method named ReadXml() which will turn that XML (w/ or w/o schema) into a DataSet, which you can bind to your GridView as its data source.
I would like to create a rdlc report at run time. I don't want to fix the columns because my query changes each time. Also, I would like to set the report layout at run time. How can this be accomplished?
This is the schema on how I programmed the visibility of the columns in my reports:
Create a tabular report with all the colums
Add a function in the report code section, the name could be IsHidden(String ColumnName)
Change the visibility of every column to =IsHidden("YourColumnName"), ColumnName needs to change every column
When executing the report:
Read the report inside an xml document
analyze the RDLC, get all the nodes with the isHidden function, replace it with True or False depending on what columns you need to show or hide.
You can select all the nodes containing the IsHidden function using this snippet:
System.Xml.XmlNodeList TableColunmnList = xmldoc.SelectNodes("rs:Report//*/rs:Visibility[rs:Hidden='=Code.IsHidden(\"" + FieldName + "\")']", xmlnsManager);
reload the RDL code using this code, XmlReport is the RDL code
System.IO.TextReader reader = new System.IO.StringReader(XmlReport);
reportViewer1.Reset();
reportViewer1.LocalReport.LoadReportDefinition(reader);
That's all, your report has dynamic visibility on all the columns.
I have a relatively simple Listview that suddenly needs (due to new requirements) to have it's 'layout' extracted to a DataTable so that a common routine can convert it to an Excel spreadsheet for export purposes.
The ItemTemplate is just a series of Table Rows with some text, data-bound labels and textboxes with validators in the cells.
Usually, when trying to pull out a particular value (like what was entered into a text box), I use the ListViewItem's .FindControl method.
For Each objItem As ListViewItem In lvwOptions.Items
Dim objTextHrsLabor As TextBox = CType(objItem.FindControl("txtHrsOptByLabor"), TextBox)
decHours = CDec(objTextHrsLabor.Text)
Next
In this case, however, I'm trying to take all the data displayed - all the 'rows and columns' of the table that was created.
Inside the ForEach / Next loop of ListViewItems, I started a ForEach/Next loop of Controls for each instance's controls but I got some really strange results returned (like controls that had a couple of table cells in them).
I get the sense I'm headed in the wrong direction. All I want is for the nicely-formatted 5-line, 6 column table to be converted to a 5-line, 6-column data table.
Is there another avenue I should be looking at?
I would look at the underlying data source for your ListView.
The data source must be a collection or an IEnumerable and you should be able to iterate through it to build your data table.
If you know that all elements are of the same type then you can use the first element and look at its properties using reflection to determine which columns your table should contain. Then you can add DataRows to your table and fill in the columns using the property names.
This will probably be faster than iterating through the generated html of the ListView.
I used this approach for exporting a ListView to Excel: http://aspalliance.com/771_CodeSnip_Exporting_GridView_to_Excel.
I know it deals with a GridView, but I adapted it to a ListView (as long as the underlying structure is a table) and it worked fine for me.
HTH.
you can use..
listView1.Items[0].SubItems[0].Text
this will be helpful , really simple and easy . You can extract info right on the basis of index & use anyway you want.