62,268
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="product_type_sel.aspx.cs" Inherits="Business_center_Function_page_Product_mailpublish_product_type_sel" %>
<%@ Register assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>产品类别选择</title>
</head>
<body style="font-weight: 700">
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TreeView ID="Tv" runat="server" ImageSet="Msdn"
onselectednodechanged="Tv_SelectedNodeChanged" ExpandDepth="1" NodeIndent="10"
ShowLines="True">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" BackColor="#CCCCCC" BorderColor="#888888"
BorderStyle="Solid" />
<SelectedNodeStyle Font-Underline="False"
HorizontalPadding="3px" VerticalPadding="1px" BackColor="White"
BorderColor="#888888" BorderStyle="Solid" BorderWidth="1px" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="1px" VerticalPadding="2px" />
</asp:TreeView>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Tv" EventName="SelectedNodeChanged">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class Business_center_Function_page_Product_mailpublish_product_type_sel : System.Web.UI.Page
{
DataSet dsTv;
private static string UserKind_Type = "01";
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack == false)
{
string strName = Member.GetUserName() ;
UserKind_Type = (Request.QueryString["UserKind_Type"] != null) ? Request.QueryString["UserKind_Type"].ToString() : "01"; //默认是供应的产品类别,01供应,02为求购,04为未定义
if (!string.IsNullOrEmpty(strName))
{
BindTV(strName,UserKind_Type);
initTree(Tv.Nodes,"0");
}
}
}
private DataSet BindTV(string UserName, string UserKind_Type)
{
car2100.BLL.Enterprise.product_purvey_info bllPurvey = new car2100.BLL.Enterprise.product_purvey_info();
dsTv = bllPurvey.GetDataKind(UserName,UserKind_Type);
return dsTv;
}
public void initTree(System.Web.UI.WebControls.TreeNodeCollection nds, string ParentID)
{
DataView dv = new DataView();
dv.Table = dsTv.Tables[0];
dv.RowFilter = "ParentnID='" + ParentID + "'";
TreeNode tnd;
foreach(System.Data.DataRowView drv in dv)
{
tnd = new TreeNode();
tnd.Value = drv.Row["TypeCode"].ToString().Trim();
tnd.Text = drv.Row["TypeName"].ToString().Trim();
nds.Add(tnd);
string tn = tnd.Value;
initTree(tnd.ChildNodes, tn);
}
}
protected void Tv_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode tn = Tv.SelectedNode;
if (tn.ChildNodes.Count > 0)
{
tn.Expanded = true;
}
else
{
string nodeText = tn.Text.Trim();
string nodeValue = tn.Value.Trim();
string script = "";
if (UserKind_Type == "01")
{
script = "<script>window.parent.SetKind('" + nodeText + "','" + nodeValue + "');</script>";
}
else if (UserKind_Type == "04")
{
script = "<script>window.parent.SetProKind('" + nodeText + "','" + nodeValue + "'); </script>";
}
ScriptManager.RegisterStartupScript(Page, this.GetType(), "OpenKind", script, false);
}
}
}