本文整理汇总了C#中System.Web.UI.WebControls.XmlDataSource.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDataSource.DataBind方法的具体用法?C# XmlDataSource.DataBind怎么用?C# XmlDataSource.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.XmlDataSource
的用法示例。
在下文中一共展示了XmlDataSource.DataBind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMenuDataSource
/// <summary>
/// Carrega os itens do menu conforme perfil logado
/// </summary>
/// <param name="menu"></param>
/// <param name="serverMapPath"></param>
/// <returns></returns>
XmlDataSource GetMenuDataSource(string menu, string serverMapPath)
{
XmlDataSource objData = new XmlDataSource();
objData.XPath = "siteMap/siteMapNode";
switch (menu)
{
case "Administrador": //Caso seja o perfil Administrador carrega o perfil setado no xml
objData.DataFile = serverMapPath + @"\App_Data\Administrador.sitemap";
break;
default:
break;
}
objData.DataBind();
return objData;
}
示例2: datafile
public static void datafile (Page p)
{
string originalxml = @"<?xml version=""1.0"" encoding=""utf-8""?><bookstore xmlns:bk=""urn:samples""><book genre=""novel"" publicationdate=""1999"" bk:ISBN=""0192100262""><title>Pride and Prejudice</title><author><first-name>Jane</first-name><last-name>Austen</last-name></author><price>24.95</price>""
</book><book genre=""novel"" publicationdate=""1985"" bk:ISBN=""0771008139""><title>The Handmaid's Tale</title><author><first-name>Margaret</first-name><last-name>Atwood</last-name></author><price>29.95</price></book></bookstore>";
XmlDataSource ds = new XmlDataSource ();
p.Form.Controls.Add (ds);
ds.DataFile = "~/XMLDataSourceTest.xml";
ds.DataBind ();
string derivedxml = ((XmlDocument) ds.GetXmlDocument ()).InnerXml;
HtmlDiff.AssertAreEqual (originalxml, derivedxml, "Loading xml");
}
示例3: HousesRpter_ItemCommand
protected void HousesRpter_ItemCommand(object source, RepeaterCommandEventArgs e)
{
LinkButton lnkUpdate = (LinkButton)e.Item.FindControl("lnkUpdate");
LinkButton lnkCancel = (LinkButton)e.Item.FindControl("lnkCancel");
LinkButton lnkEdit = (LinkButton)e.Item.FindControl("lnkEdit");
LinkButton lnkDelete = (LinkButton)e.Item.FindControl("lnkDelete");
#region Edit
if (e.CommandName == "edit")
{
lnkCancel.Visible = true;
lnkUpdate.Visible = true;
lnkEdit.Visible = false;
int houseId = int.Parse(e.CommandArgument.ToString());
int doc = GetHomeDocID(houseId);
object returningValue;
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand newcmd = new SqlCommand("SELECT theDoc FROM XMLDoc WHERE id=" + doc, con))
{
newcmd.CommandType = CommandType.Text;
con.Open();
returningValue = newcmd.ExecuteScalar();
con.Close();
}
}
HouseDoc.InnerXml = (string)returningValue;
XmlDataSource homeDatasource = new XmlDataSource();
homeDatasource.Data = HouseDoc.InnerXml;
homeDatasource.EnableCaching = false;
homeDatasource.DataBind();
AddHomeForm.DataSourceID = null;
AddHomeForm.DataSource = homeDatasource;
AddHomeForm.ChangeMode(FormViewMode.Edit);
AddHomeForm.DataBind();
AddHomeForm.Visible = true;
}
#endregion
#region Update
if (e.CommandName == "update")
{
lnkCancel.Visible = false;
lnkUpdate.Visible = false;
lnkEdit.Visible = true;
EditHouse edit = (EditHouse)AddHomeForm.FindControl("EditHouse1");
string HouseName = ((TextBox)edit.FindControl("HouseNameTextBox")).Text;
string HouseLat = ((TextBox)edit.FindControl("HouseLatTextBox")).Text;
string HouseLong = ((TextBox)edit.FindControl("HouseLongTextBox")).Text;
int houseId = int.Parse(e.CommandArgument.ToString());
House house = new House();
house.HouseID = houseId;
house.HouseName = HouseName;
house.HouseDescription = "House Description";
int docID = UpdateHouse(house);
XmlNode name = HouseDoc.SelectSingleNode("home/name");
name.InnerText = HouseName;
XmlNode longitude = HouseDoc.SelectSingleNode("home/longitude");
longitude.InnerText = HouseLong;
XmlNode latitude = HouseDoc.SelectSingleNode("home/latitude");
latitude.InnerText = HouseLat;
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("UpdateHouseXML", con))
{
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter userId = new SqlParameter("@Original_id", docID);
SqlParameter roleId = new SqlParameter("@thedoc", HouseDoc.InnerXml);
cmd.Parameters.Add(userId);
cmd.Parameters.Add(roleId);
con.Open();
cmd.ExecuteScalar();
con.Close();
}
}
SqlDataSource1.DataBind();
HousesRpter.DataBind();
AddHomeForm.Visible = false;
}
#endregion
#region Cancel
if (e.CommandName == "cancel")
//.........这里部分代码省略.........
示例4: ListView1_PreRender
protected void ListView1_PreRender(object sender, EventArgs e)
{
ListView listview = (ListView)sender;
ListViewItem item = (ListViewItem)listview.Parent;
HtmlControl htmlDivControl = (HtmlControl)item.FindControl("CheckBox1");
HiddenField hidden = (HiddenField)item.FindControl("RoomName");
string str = "//rooms/room[name/text()='"+hidden.Value+"']/devices/device";
XmlDataSource src = new XmlDataSource();
src.Data = HouseDoc.InnerXml;
src.TransformFile = "~/XML/StateTransform.xslt";
src.XPath = str;
src.DataBind();
src.EnableCaching = false;
src.ID = "srcDevices";
listview.DataSource = src;
listview.DataBind();
}
示例5: GetXmlDataSource
private XmlDataSource GetXmlDataSource(DataTable topParents, DataTable childrenAndParents)
{
XmlDocument doc = new XmlDocument();
XmlNode rootNode = doc.CreateElement("root");
doc.AppendChild(rootNode);
foreach (DataRow drParent in topParents.Rows)
{
XmlNode topParent = doc.CreateElement("person");
XmlAttribute ID = doc.CreateAttribute("ID");
ID.Value = drParent["ParentID"].ToString();
topParent.Attributes.Append(ID);
XmlAttribute Name = doc.CreateAttribute("name");
Name.Value = drParent["Name"].ToString();
topParent.Attributes.Append(Name);
rootNode.AppendChild(topParent);
}
int inc = childrenAndParents.Rows.Count;
for (int i = 0; i < inc; i++)
{
foreach (DataRow drChild in childrenAndParents.Rows)
{
string parentID = drChild["ParentID"].ToString();
string childID = drChild["ChildID"].ToString();
XmlNodeList nl = doc.GetElementsByTagName("person");
foreach (XmlNode node in nl)
{
if (node.Attributes["ID"].Value == parentID)
{
XmlNode child = doc.CreateElement("person");
XmlAttribute ID = doc.CreateAttribute("ID");
ID.Value = childID;
child.Attributes.Append(ID);
XmlAttribute Name = doc.CreateAttribute("name");
Name.Value = "Fake Name " + childID;
child.Attributes.Append(Name);
node.AppendChild(child);
}
}
}
inc--;
}
XmlDataSource xmlDataSource = new XmlDataSource();
xmlDataSource.ID = "dsTreeView";
xmlDataSource.Data = doc.OuterXml;
xmlDataSource.XPath = "root/parent";
xmlDataSource.DataBind();
return xmlDataSource;
}