开发者

how to hide a checkbox inside a datagrid?

i have datagrid and inside which i have a checkbox . now i want this check to be hidden at page load. my code is :

<asp:datagrid id="dgDates" OnItemCommand="gridEventHandler" BorderColor="Black" BorderWidth="1px"
CellPadding="3" runat="server" AutoGenerateColumns="False" HorizontalAlign="Left" All开发者_StackOverflow中文版owSorting="True"
OnSortCommand="SortData" OnItemDataBound="gridItemDataBound">
<HeaderStyle Font-Underline="True" Font-Bold="True" HorizontalAlign="Center" ForeColor="Black"
    BackColor="#D4D0C8"></HeaderStyle>
<Columns>
    <asp:BoundColumn DataField="strParameterName" SortExpression="strParameterName" HeaderText="Parameter Name"></asp:BoundColumn>
    <asp:BoundColumn DataField="dtParameterValue" SortExpression="dtParameterValue" HeaderText="Parameter Value"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Constant" SortExpression="blnStatic" ItemStyle-HorizontalAlign="Center">
        <ItemTemplate>
            <asp:CheckBox ID="cbStaticRolling" Checked="False" Runat="server" ></asp:CheckBox>
        </ItemTemplate>
    </asp:TemplateColumn>
</Columns>


Handle the ItemDataBound event

public void gridItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || 
            e.Item.ItemType == ListItemType.AlternatingItem)
        {
            CheckBox cbStaticRolling= (CheckBox)e.Item.FindControl("cbStaticRolling");
            cbStaticRolling.Visible = false;
        }
    }


<asp:CheckBox ID="cbStaticRolling" Checked="False" Visible="False" Runat="server" >
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜