是否必須使用XPath將我的XML文檔 鏈接到中繼器,或者有其他方法。xml和中繼器
這是我的一些代碼。通過數據和存儲
第一頁環路XML:
public virtual void Button_Click(object sender, EventArgs args)
{
TableControl recControls = (TableControl)this.Page.FindControlRecursively("TableControl");
if (recControls != null)
{
TableControlRow[] rows = recControls.GetSelectedRecordControls();
this.Page.Session["RegistrationTableControl"] = rows;
// create XML writer to
using(System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(@"c:\temp\reg.xml"))
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.CloseOutput = false;
writer.WriteStartDocument();
writer.WriteStartElement("SubContractors");
foreach(TableControlRow rec in rows)
{
writer.WriteElementString("SubContrator1", rec.BUSINESSNAME.Text);
writer.WriteElementString("SubContactName1", rec.OWNERNAME.Text);
writer.WriteElementString("SubAddress1", rec.ADDRESS.Text);
writer.WriteElementString("SubCity1", rec.CITY.Text);
writer.WriteElementString("SubState1", rec.STATE.Text);
writer.WriteElementString("SubZipCode1", rec.ZIPCODE.Text);
writer.WriteElementString("SubPhone1", rec.PHONE.Text);
writer.WriteElementString("SubFax1", rec.FAX.Text);
writer.WriteElementString("SubEmail1", rec.EMAIL.Text);
writer.WriteElementString("Status1", "Please enter information");
writer.WriteElementString("Referral", "1");
}
writer.WriteEndElement();
writer.WriteEndDocument();
}
}}
它創建我的XML文檔。代碼:我需要在新創建的XML文檔中獲取數據,然後使用此代碼填充我的表格控件中繼器。
2頁
public override void DataBind()
{
base.DataBind();
// Make sure that the DataSource is initialized.
if (this.DataSource == null)
{
return;
}
// Setup the pagination controls.
BindPaginationControls();
// Populate all filters data.
// Bind the repeater with the list of records to expand the UI.
System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)(this.FindControl("TableControlRepeater"));
rep.DataSource = this.DataSource;
rep.DataBind();
int index = 0;
foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items)
{
// Make sure that the DataSource is initialized.
// Loop through all rows in the table, set its DataSource and call DataBind().
TableControlRow recControl = (TableControlRow)(repItem.FindControl("TableControlRow"));
recControl.DataSource = this.DataSource[index];
recControl.DataBind();
recControl.Visible = !this.InDeletedRecordIds(recControl);
index += 1;
}
}
對我採取XML數據並將其放置在成爲中繼器的數據源2頁。
任何幫助或建議是非常有益的。我真的不需要重寫代碼。
是... ...有你將一切XML(用手,太)和原因,然後回讀? – 2011-03-05 02:22:54