views:

82

answers:

0

I've migrated VS 2005 Web Site Project to VS 2005 Web Application Project. And find out that html which generated by my DataList control was changed. There is ItemTemplate:

<ItemTemplate>
    <asp:Label ID="CellLabel" runat="server" Text='<%# Eval("Cell") %>' Visible='<%# Eval("Cell").ToString() != "0" %>' />
    <asp:TextBox ID="CellTextBox" runat="server" Text='<%# Bind("Cell") %>' Visible='<%# Eval("Cell").ToString() == "0" %>' />
</ItemTemplate>

Now it always generate span, intead of span and input. To bind DataList control i use DataSource property. My page code:

public void Page_Load(Object sender, EventArgs e)
{
  if (!this.IsPostBack)
    myControl.DataBind();
}

MyControl (which contains DataList control) code:

public class Mycontrol
{
    private DataTable myDataTable = null;
        public DataTable MyDataTable;
        {
            set { Context.Session["MyDataTable"] = myDataTable = value; }

            get
            {
                if (myDataTable != null)
                    return myDataTable;

                if (Context.Session != null && Context.Session["MyDataTable"] != null)
                {
                    myDataTable = (DataTable)Context.Session["MyDataTable"];
                }
                else
                {
                    myDataTable = GetData();
                    Context.Session["MyDataTable"] = myDataTable;
                }
                return myDataTable;
            }
        }

        public override void DataBind()
        {
            MyDataList.DataSource = MyDataTable;
            MyDataList.DataBind();
        }

    protected void CheckButton_Click(object sender, EventArgs e)
    {
    // There is MyDataTable
    }
}

It would be a simple table on the page, which has some initial cells and another user should enter. Could i use Datalist control to implement it? And could i use ItemTemplate to let user enter some cells and get it after postback?