none
自定义页面集成到CRM中的问题 RRS feed

  • 问题

  • 各位高手:

          现项目中遇到自定义页面,需用到DropDownList,Panel等服务器控件,

          DropDownList 是动态从数据中绑定,

          发布和调试的页面程序可以正常运行,但如果把其页面放到CRM的ISV文件中或新建的虚拟目录中

          DropDownList 在页面加载时绑定数据,但是如果点击button按钮(无相关事件)后,页面刷新后DropDownList 不再绑定原有数据。下拉框中选项被清空。但是如果在文本框中输入数据,在点击按钮后,还会显示。

    请各位高手指教。

    代码如下:
    页面文件Default.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestSample._Default" %>
    
    <%--<!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>
        <link rel="stylesheet" type="text/css" href="Css/TestSample.css"/>
        <link rel="stylesheet" type="text/css" href="Css/fonts.css"/>
    </head>
    <body class="stage">
        <form id="form1" runat="server">
            <table class="ms-crm-ListControl" cellpadding="0" cellspacing="0" >
                <tr align="left" >
                    <td align="left">
                        <div style="height: 99.9%; padding:10px" class="ms-crm-List-DataArea">
                            <table cellpadding="0" cellspacing="0" style="width:100%; border-style:none;">
                                <tr style="border-style:none;">
                                    <td colspan="2" 
                                        style="border-style:none none solid none; font-size: 20; font-weight: bold; color: #FF3300; border-bottom-width: thin; border-bottom-color: #FF3300;" 
                                        height="28px">
                                        &nbsp;&nbsp;CRM Custom Page Question</td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td colspan="2" style="border-style:none;" height="10px"></td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td class="OneCellLeft" style="font-weight: bold;" align="center" width="160px" 
                                        height="28px">
                                        文本框:</td>
                                    <td class="OneCellRight" align="left" >
                                        &nbsp;&nbsp;<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td class="OneCellLeft" style="font-weight: bold;" align="center" width="160px" 
                                        height="28px">
                                        下拉框(PickList):</td>
                                    <td class="OneCellRight" align="left" >
                                        &nbsp;&nbsp;<asp:DropDownList ID="DropDownList1" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td colspan="2" style="border-style:none;" height="10px"></td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td style="border-style:none;" align="left" width="160px" height="28px">
                                        &nbsp;&nbsp;&nbsp;<asp:Button CssClass="ms-crm-Button" ID="Button1" runat="server" Text="报表列印" />
                                    </td>
                                    <td style="border-style:none;" align="left">
                                    </td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td colspan="2" style="border-style:none;" height="100%"></td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
    </body>
    </html>
    

    页面代码文件Default.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    
    namespace TestSample
    {
        public partial class _Default : System.Web.UI.Page
        {
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    DataTable table = GetDataSource();
                    this.DropDownList1.DataSource = table.DefaultView;
                    this.DropDownList1.DataValueField = "PickListVlaue";
                    this.DropDownList1.DataTextField = "PickListText";
                    this.DropDownList1.DataBind();
                }
            }
    
            private static DataTable GetDataSource()
            {
                DataColumn column = new DataColumn();
                DataTable table = new DataTable();
                DataRow MyRow;
                table.Columns.Clear();
                column = new DataColumn();
                column.DataType = System.Type.GetType("System.Int32");
                column.ColumnName = "PickListVlaue";
                table.Columns.Add(column);
    
                column = new DataColumn();
                column.DataType = Type.GetType("System.String");
                column.ColumnName = "PickListText";
                table.Columns.Add(column);
    
                for (int i = 1; i < 11; i++)
                {
                    MyRow = table.NewRow();
                    MyRow["PickListVlaue"] = i;
                    MyRow["PickListText"] = "DynamicPickList" + i.ToString();
                    table.Rows.Add(MyRow);
                }
                return table;
            }
        }
    }
    

    Style文件:
    TestSample.css
    BODY
    {
    	direction: LTR;
    	margin:	0px;
    	border: 0px;
    	background-color: #d6e8ff;
    	cursor: default;
    	scrollbar-3dlight-color:#6699CC;
    	scrollbar-arrow-color:#567DB1;
    	scrollbar-base-color:#D6E8FF;
    	scrollbar-darkshadow-color:#6699CC;
    	scrollbar-face-color:white;
    	scrollbar-highlight-color:#D6E8FF;
    	scrollbar-shadow-color:#D6E8FF;
    }
    
    BODY.stage
    {
    	border-top:1px solid #6893cf;
    	background-color: #d6e8ff;
    	padding: 4px;
    	background-repeat: repeat-x;
    	background-image: url('/Imgs/app_back.gif');
    }
    
    TABLE.ms-crm-ListControl
    {
    	border: solid 1px #6699CC;
    	height: 100%;
    	width: 100%;
    	table-layout: fixed;
    	background-color: #FFFFFF;
    }
    
    DIV.ms-crm-List-DataArea
    {
    	overflow-x: auto;
    	overflow-y: auto;
    	width: 100%;
    	height: 100%;
    	background-color: #FFFFFF;
    }
    TD
    {
    	white-space: nowrap;
    }
    TD.FirstCellLeft
    {
    	text-align:center;
    	vertical-align:middle;	
    	border-width:0px;
    	font-weight:bold;
    	background-color:#F3F1F1;
    	font-size:smaller;
    	border-top-style: solid;
    	border-top-width: 2px; 
    	border-top-color: #F3F1F1;
    	border-bottom-style: solid;
    	border-bottom-width: 1px; 
    	border-bottom-color: #FFFFFF;
    }
    
    TD.FirstCellRight
    {
    	vertical-align:middle;	
    	border-width:0px;
    	font-size:smaller;
    	border-top-style: solid;
    	border-top-width: 2px; 
    	border-top-color: #F3F1F1;
    	border-bottom-style: solid;
    	border-bottom-width: 1px; 
    	border-bottom-color: #F3F1F1;
    }
    
    TD.CellLeft
    {
    	text-align:center;
    	vertical-align:middle;	
    	border-width:0px;
    	font-weight:bold;
    	background-color:#F3F1F1;
    	font-size:smaller;
    	border-bottom-style: solid;
    	border-bottom-width: 1px; 
    	border-bottom-color: #FFFFFF;
    }
    
    TD.CellRight
    {
    	vertical-align:middle;	
    	border-width:0px;
    	font-size:smaller;
    	border-bottom-style: solid;
    	border-bottom-width: 1px; 
    	border-bottom-color: #F3F1F1;
    }
    
    TD.LastCellLeft
    {
    	text-align:center;
    	vertical-align:middle;	
    	border-width:0px;
    	font-weight:bold;
    	background-color:#F3F1F1;
    	font-size:smaller;
    	border-bottom-style: solid;
    	border-bottom-width: 2px; 
    	border-bottom-color: #F3F1F1;
    }
    
    TD.LastCellRight
    {
    	vertical-align:middle;	
    	border-width:0px;
    	font-size:smaller;
    	border-bottom-style: solid;
    	border-bottom-width: 2px; 
    	border-bottom-color: #F3F1F1;
    }
    
    TD.OneCellLeft
    {
    	text-align:center;
    	vertical-align:middle;	
    	border-width:0px;
    	font-weight:bold;
    	background-color:#F3F1F1;
    	font-size:smaller;
    	border-top-style: solid;
    	border-top-width: 2px; 
    	border-top-color: #F3F1F1;
    	border-bottom-style: solid;
    	border-bottom-width: 2px; 
    	border-bottom-color: #F3F1F1;
    }
    
    TD.OneCellRight
    {
    	vertical-align:middle;	
    	border-width:0px;
    	font-size:smaller;
    	border-top-style: solid;
    	border-top-width: 2px; 
    	border-top-color: #F3F1F1;
    	border-bottom-style: solid;
    	border-bottom-width: 2px; 
    	border-bottom-color: #F3F1F1;
    }
    
    INPUT,
    TEXTAREA,
    SELECT
    {
    	color: #000000;
    	font-size: 12px;
    	border:1px solid #6699cc;
    }
    
    INPUT.ms-crm-Button
    {	
    	font-family: Tahoma;
    	font-size: 12px;
    	line-height: 18px;
    	height: 20px;
    	width: 84px;
    	text-align: center;
    	cursor: pointer;
    	border: 1px #3366CC solid;
    	background-color: #CEE7FF;
    	background-image: url('/Imgs/btn_rest.gif');
    	background-repeat: repeat-x;
    	padding-left: 5px;
    	padding-right: 5px;
    }
    
    TD.THCell
    {
    	text-align:center;
    	vertical-align:middle;	
    	font-weight:bold;
    	border-width:0px;
    	background-color:#F3F1F1;
    	font-size:smaller;
    	border-left-style: solid;
    	border-left-width: 1px; 
    	border-left-color: #FFFFFF;
    	border-right-style: solid;
    	border-right-width: 1px; 
    	border-right-color: #FFFFFF;
    	white-space: nowrap;
    }



    2009年4月21日 9:05

答案

全部回复