软件下载 | 资讯教程 | 最近更新 | 下载排行 | 一键转帖 | 发布投稿
您的位置:最火下载站 > 网络编程 > ASP教程 > dropdownlist绑定带有制表符的数据时变形

dropdownlist绑定带有制表符的数据时变形

  烈火网(LieHuo.Net)教程

  想做成那种显示层次结构的下拉菜单,结果输入的制表符变得不整齐,保存成html文档打开就正常,下面是代码和图:

以下为引用的内容:
/// <summary>
/// 绑定父级部门下拉菜单
/// </summary>
private void bindFatherDepartment()
{
DataTable dt = creatDepartmentTable();
ddlFatherDepartment.DataSource = dt;
ddlFatherDepartment.DataTextField = "DepartmentName";
ddlFatherDepartment.DataValueField = "DepartmentID";
ddlFatherDepartment.DataBind();
ddlFatherDepartment.Items.Insert(0, "请选择……");
dt.Dispose();
}
/// <summary>
/// 构造作为数据源的datatable
/// </summary>
/// <returns></returns>
private DataTable creatDepartmentTable()
{
DepartmentsDS.DepartmentsDataTable result = new DepartmentsDS.DepartmentsDataTable();

DataSet DS = DBiz.getOrganizationList();
DataTable DT = DS.Tables[0];
for (int i = 0; i < DT.Rows.Count; i++)
{
result.Rows.Add(DT.Rows[i].ItemArray);
creatFatherDepartmentTable1(result, DT.Rows[i]["DepartmentID"].ToString());
}
DT.Dispose();
DS.Dispose();
return result;
}
/// <summary>
/// 添加带线的数据行
/// </summary>
/// <param name="target"></param>
/// <param name="ID"></param>
private void creatFatherDepartmentTable1(DataTable target,string ID)
{
DataSet DStemp = DBiz.getChildListByID(ID);
DataTable DTtemp = DStemp.Tables[0];
for (int i = 0; i < DTtemp.Rows.Count; i++)
{
DataRow DR = DTtemp.Rows[i];

//构造DR内容 LIEHUO.NET
DataRow tempDR = DR;
DataRow fatherDR = DBiz.getByID(tempDR["DepartmentSuperiorID"].ToString()).Tables[0].Rows[0];
for (int j = 0; j < (DR["DepartmentGUID"].ToString().Length/5 -1); j++)
{
if (j == 0)
{
if (Convert.ToI

  正确答案:

  如果你保存成html正常,多半是因为css不一致引起,修改dropdownlist样式,或建议你直接包装成一个自定义的drodownlist,将字符集的样式写死在最内层。

    相关阅读
    栏目导航
    推荐软件