试试 (bool)字段名

解决方案 »

  1.   

    Oracle里没有Bool这个类型啊
      

  2.   

    Checked='<%#DataBinder.Eval(Container.DataItem,"数据库字段").ToString()=="1"%>'> 
      

  3.   

    我的办法比较笨,希望对你有用。就是把那一列转换为模板列,删除原来的控件,添加一个label和一个checkBox,
    label单向绑定那个字段。运行时的代码如下:
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Label lbl1;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.RowState == DataControlRowState.Edit || (e.Row.RowState == (DataControlRowState)5))
                {
                    lbl1 = (Label)e.Row.Cells[6].Controls[1];
                    lbl1.Visible = false;
                    CheckBox cb1 = (CheckBox)e.Row.Cells[6].Controls[3];
                    try
                    {
                        int i1 = int.Parse(lbl1.Text);
                        if (i1 > 0) cb1.Checked = true;
                        else cb1.Checked = false;
                    }
                    catch
                    {
                        cb1.Checked = false;
                    }
                }
            }
        }
      

  4.   

    直接绑定上去就可以了.
                                        <Columns>
                                            <asp:TemplateField>
                                                <HeaderStyle CssClass="CheckColumn" />
                                                <ItemStyle CssClass="CheckColumn" />
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="asp_chbIsChecked" Checked='<%# DataBinder.Eval(Container, "DataItem.IsChecked") %>' runat="server" />                                        
                                                </ItemTemplate>
                                            </asp:TemplateField></Columns>
    后台绑定就行了.