i am editing a devolped solution the problem is that check boxes are need in the datagrid but data is viewed in the datagrid without checkbox which exist but not viewed

Dani AI

Generated

Brief diagnosis and focused checklist based on the symptom and the replies from and .

Common causes (check in this order)

  • Confirm the CheckBox is inside an ItemTemplate (not only an EditItemTemplate). Edit templates render only when the row is in edit mode.
  • Confirm the CheckBox has runat="server" if it is intended to be a server control.
  • Verify no Visible="false" on the column (TemplateColumn/TemplateField) or on the CheckBox itself, either in markup or set in code-behind (Page_Load, ItemDataBound, etc.).
  • If AutoGenerateColumns="true" is being used, TemplateColumns may not be applied as expected. Set AutoGenerateColumns="false" and declare columns explicitly.
  • If columns are added dynamically, ensure they are recreated on every postback before calling DataBind() (dynamic controls must be recreated early in the page lifecycle).
  • Inspect the rendered HTML (view source / browser dev tools) to see if input type="checkbox" exists but is hidden by CSS (display:none, visibility:hidden, width/overflow, or a z-index issue).
  • Check for any ItemDataBound/ItemCreated handlers that may hide or remove the CheckBox at runtime.

Small VB.NET example (DataGrid TemplateColumn + ItemDataBound)

<asp:DataGrid id="dg" runat="server" AutoGenerateColumns="False">
  <asp:TemplateColumn>
    <ItemTemplate>
      <asp:CheckBox ID="chkSelect" runat="server" />
    </ItemTemplate>
  </asp:TemplateColumn>
</asp:DataGrid>
Protected Sub dg_ItemDataBound(sender As Object, e As DataGridItemEventArgs) _
    Handles dg.ItemDataBound
  If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
    Dim chk As CheckBox = CType(e.Item.FindControl("chkSelect"), CheckBox)
    If chk IsNot Nothing Then chk.Visible = True
  End If
End Sub

Relevant documentation: DataGrid Class and TemplateColumn Class.

Recommended Answers

All 2 Replies

Um, what?
Can you form that question a little better?

in which template u hav taken the checkboxes in datagrid .if u take them in ItemTemplate then set visible attribute to false

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.