[整理]VS2005,DetailsView1控件学习记录。

I Use Visual Studio 2005 In My Project,Today I Find Some Problem.
in my sql server 2005 database,there have a field(bit),i use the controls DetailsView,for show the Detail info.
because the type bit's value true or false,but i can not to show true or false,i want to show the lock or unlock,here is the resolvent.

note 1 ---use sql.
this is the code:"select userlock=(case when userlock=0 then 'lock' else 'unlock' end)" form tablename";

note 2 --- use databound
    protected void DetailsView1_DataBound(object sender, EventArgs e)
    {
        Label LabTemp = (Label)DetailsView1.FindControl("Label1");
        if (LabTemp.Text == "True")
        {
            LabTemp.Text = "lock";
        }
        else
        {
            LabTemp.Text = "unlock";
        }
    }
上面第二条解决方法,必须将该列转化成模板列才行,否则是没办法改变显示的。

原文地址:https://www.cnblogs.com/Apollo/p/364139.html