使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中
来源:互联网 发布:网络家教平台有哪些 编辑:程序博客网 时间:2024/06/05 06:35
Demo4.aspx文件:
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 141px;
}
.style2
{
width: 200px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
书名:<asp:DropDownList ID="DropDownList1" runat="server" Height="25px"
Width="184px">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Xonclick="Button1_Click" Text="显示详情" />
<br />
<table style="width:100%;">
<tr>
<td class="style1">
作者:</td>
<td class="style2">
<asp:TextBox ID="Txtauthor" runat="server" Width="199px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style1">
出版社:</td>
<td class="style2">
<asp:TextBox ID="Txtpublisher" runat="server" Width="198px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style1">
出版年月:</td>
<td class="style2">
<asp:TextBox ID="TxtYear" runat="server" Width="199px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style1">
Isbn号:</td>
<td class="style2">
<asp:TextBox ID="TxtISbn" runat="server" Width="199px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style1">
价格:</td>
<td class="style2">
<asp:TextBox ID="txtprice" runat="server" Width="199px"></asp:TextBox>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
Demo4.aspx.cs文件:
XmlDocument xdoc;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
xdoc = new XmlDocument();
xdoc.Load(Server.MapPath("books.xml"));
XmlNodeList list = xdoc.GetElementsByTagName("name");
foreach (XmlNode node in list)
{
this.DropDownList1.Items.Add(node.InnerText);
}
Session["doc"] = xdoc;
}
else
{
xdoc=Session["doc"] as XmlDocument;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
XmlNode node = xdoc.DocumentElement.SelectSingleNode("book[name='" + this.DropDownList1.Text + "']");
#region 方法1
foreach (XmlNode item in node.ChildNodes)
{
if (item.LocalName == "author")
{
this.Txtauthor.Text = item.InnerText;
}
if (item.LocalName == "publisher")
{
this.Txtpublisher.Text = item.InnerText;
}
if (item.LocalName == "date")
{
this.TxtYear.Text = item.InnerText;
}
if (item.LocalName == "isbn")
{
this.TxtISbn.Text = item.InnerText;
}
if (item.LocalName == "price")
{
this.txtprice.Text = item.InnerText;
}
}
#endregion
//#region 方法2
//Txtauthor.Text = node.SelectSingleNode("author").InnerText;
//Txtpublisher.Text = node.SelectSingleNode("publisher").InnerText;
//TxtYear.Text = node.SelectSingleNode("date").InnerText;
//TxtISbn.Text = node.SelectSingleNode("isbn").InnerText;
//txtprice.Text = node.SelectSingleNode("price").InnerText;
//#endregion
}
- 使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中。
- 使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中
- 5使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中。
- 使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中
- 使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中。添加 :删除按钮,修改并保存按钮 和 添加按钮。完成这些按钮所对应的功能(XmlDocument)
- 使用XmlDocument 读取books.xml中的书名到DropDownList中
- 使用XmlDocument 读取books.xml中的书名到DropDownList中
- 使用XmlDocument 读取books.xml中的书名到DropDownList中。(4-2选作使用XmlReader读取books.xml中的书名到DropDownList中)
- 将一个文本里的信息,读入到 list 中
- 文本框中显示灰色的提示信息
- 显示在文本框中输入的信息
- 从配置文件读取相应的信息加载到应用程序中
- 使用perl将当前目录中子目录下的相应文件拷贝到一个文件夹中
- 在WINFORM中,通过文本框textBox搜索定位到treeview的相应的结点?
- 使用cookie技术实现,缓存最近浏览过详细信息的三本书的书名列表,并进行相应显示
- mvc中dropdownlist的使用
- C++图像处理中从硬盘读入图像文件,并将相应数据赋值给图像类的char**data成员
- 改变下拉列表的值 追加显示到文本框中
- 使用XlmWrite把一个xml文件写入输出流中在(demo2.aspx运行时显示xml文档)
- label 显示文字过多以省略号表示(.NET)
- ios Socket使用大全
- 使用XmlDocument 读取books.xml中的书名到DropDownList中
- [Delphi]NMSMTP控件發送郵件
- 使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中
- hdu 1513 滚动数组优化 回文串
- LCD最新资料大全
- javascript获取鼠标位置部分火狐,ie
- SQL批量添加主键脚本
- .NET FrameWork 小记 (Value Types,Refrence Types, difference)
- SQL Server 2005 没有本地发布选项
- 红帽5下Postfix的设置
- 1.使用 GridView 控件和 SqlDataSource 控件显示乐知 班学生名单