Thanks for the response but it still isn't working correctly... More
details....
Grid Definition...
<asp:datagrid id="dgEquipment " tabIndex="50" runat="server"
Width="664px" BackColor="Whit e" BorderColor="#C CCCCC"
ToolTip="Equipm ent at this location" EnableViewState ="true"
PageSize="9999" CellPadding="3"
AutoGenerateCol umns="False" BorderWidth="1p x" BorderStyle="No ne">
<SelectedItemSt yle Font-Size="Smaller" Font-Names="Arial"
Font-Bold="True" ForeColor="Whit e" BackColor="#669 999"></SelectedItemSty le>
<EditItemStyl e Font-Size="Larger" Font-Names="Arial"></EditItemStyle>
<AlternatingIte mStyle Font-Size="XX-Small"
Font-Names="Arial"></AlternatingItem Style>
<ItemStyle Font-Size="XX-Small" Font-Names="Arial"
ForeColor="#000 066"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="Arial" Font-Bold="True"
ForeColor="Blac k" BackColor="#D3F 2FE"></HeaderStyle>
<FooterStyle ForeColor="#000 066" BackColor="Whit e"></FooterStyle>
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox runat="server" AutoPostBack="f alse"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
<PagerStyle Font-Size="Smaller" Font-Names="Arial"
HorizontalAlign ="Left" ForeColor="#000 066"
BackColor="Whit e" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
Private Sub InitGrid()
' Add the columns programmaticall y since we will eventually let the
users define which columns are displayed...
If dgEquipment.Col umns.Count <= 1 Then
Dim col As BoundColumn
col = New BoundColumn
col.HeaderText = "Counter"
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Left
col.DataField = "Counter"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
col.Visible = False
dgEquipment.Col umns.Add(col)
col = New BoundColumn
col.HeaderText = "Make"
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Left
col.DataField = "MFG"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
dgEquipment.Col umns.Add(col)
col = New BoundColumn
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Left
col.HeaderText = "Model"
col.DataField = "MODEL"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
dgEquipment.Col umns.Add(col)
col = New BoundColumn
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Left
col.HeaderText = "Serial #"
col.DataField = "SERIAL"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
dgEquipment.Col umns.Add(col)
col = New BoundColumn
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Right
col.HeaderText = "Install Date"
col.DataField = "INSTALL"
col.DataFormatS tring = "{0:d}"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
dgEquipment.Col umns.Add(col)
col = New BoundColumn
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Right
col.HeaderText = "Warranty"
col.DataField = "Warranty"
col.DataFormatS tring = "{0:d}"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
dgEquipment.Col umns.Add(col)
col = New BoundColumn
col.HeaderStyle .HorizontalAlig n = HorizontalAlign .Center
col.ItemStyle.H orizontalAlign = HorizontalAlign .Right
col.HeaderText = "Agreement #"
col.DataField = "SerAgrNo"
col.ItemStyle.F ont.Name = "Arial"
col.ItemStyle.F ont.Size = System.Web.UI.W ebControls.Font Unit.XXSmall
dgEquipment.Col umns.Add(col)
End If
End Sub
Private Sub LoadGrid()
' Equipment Grid
Dim equip As New clsEquip
equip.InitDBCon nection(Session ("ConnectionStr ing"))
equip.Load(Sess ion("CustNo"), Session("LocNo" ))
dgEquipment.Dat aSource = equip
DataBind()
equip = Nothing
End Sub
With the following the grid displays all the data and the checkbox
correctly. But when I click any button on the screen any checks I have made
are cleared so I can't check and see what the user checked....
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If IsPostBack Then
' Do some stuff here
Else
' Do other stuff here
End If
InitGrid()
LoadGrid()
Exit Sub
With this one the second time around the grid is empty except for the
checkbox column...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If IsPostBack Then
' Do some stuff here
Else
' Do other stuff here
InitGrid()
LoadGrid()
End If
Exit Sub
I am sure I am just missing something. Thanks in advance!
Bob
"Ather Ali Shaikh" <at*******@eint elligencesoft.c om> wrote in message
news:OD******** *****@tk2msftng p13.phx.gbl...
are you using the checkbox attribute AutoPostBack = True
make it False.
if it is required to make true then set the code
If IsPostBack Then
else
> BIND DATA HERE
end if
Regards
Ather Ali Shaikh
"Bob Trabucco" <bo**@ccc-soft.com> wrote in message
news:#8******** ******@TK2MSFTN GP11.phx.gbl... Hello all,
I have a Datagrid on a page. 1 column is a template column with a
checkbox (unbound). The rest of the columns are databound that are added
programatically .
If in the Page_Load I do:
If IsPostBack Then
else
end if
BIND DATA HERE
Then the grid displays correctly every time but the checkboxes are
always cleared so I can never check them.
If I do this...
If IsPostBack Then
else
BIND DATA HERE
end if
The grid posts back the first time but the second pass the grid is
empty!
Any clues to what I am doing wrong?
Thanks in advance,
Bob