473,474 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagrid Postback issues

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
Nov 18 '05 #1
2 1555
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**************@TK2MSFTNGP11.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

Nov 18 '05 #2
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="White" BorderColor="#CCCCCC"
ToolTip="Equipment at this location" EnableViewState="true"
PageSize="9999" CellPadding="3"
AutoGenerateColumns="False" BorderWidth="1px" BorderStyle="None">
<SelectedItemStyle Font-Size="Smaller" Font-Names="Arial"
Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
<EditItemStyle Font-Size="Larger" Font-Names="Arial"></EditItemStyle>
<AlternatingItemStyle Font-Size="XX-Small"
Font-Names="Arial"></AlternatingItemStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Arial"
ForeColor="#000066"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="Arial" Font-Bold="True"
ForeColor="Black" BackColor="#D3F2FE"></HeaderStyle>
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox runat="server" AutoPostBack="false"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Font-Size="Smaller" Font-Names="Arial"
HorizontalAlign="Left" ForeColor="#000066"
BackColor="White" Mode="NumericPages"></PagerStyle>
</asp:datagrid>

Private Sub InitGrid()

' Add the columns programmatically since we will eventually let the
users define which columns are displayed...
If dgEquipment.Columns.Count <= 1 Then

Dim col As BoundColumn

col = New BoundColumn
col.HeaderText = "Counter"
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Left
col.DataField = "Counter"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
col.Visible = False
dgEquipment.Columns.Add(col)

col = New BoundColumn
col.HeaderText = "Make"
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Left
col.DataField = "MFG"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
dgEquipment.Columns.Add(col)

col = New BoundColumn
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Left
col.HeaderText = "Model"
col.DataField = "MODEL"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
dgEquipment.Columns.Add(col)

col = New BoundColumn
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Left
col.HeaderText = "Serial #"
col.DataField = "SERIAL"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
dgEquipment.Columns.Add(col)

col = New BoundColumn
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Right
col.HeaderText = "Install Date"
col.DataField = "INSTALL"
col.DataFormatString = "{0:d}"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
dgEquipment.Columns.Add(col)

col = New BoundColumn
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Right
col.HeaderText = "Warranty"
col.DataField = "Warranty"
col.DataFormatString = "{0:d}"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
dgEquipment.Columns.Add(col)

col = New BoundColumn
col.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col.ItemStyle.HorizontalAlign = HorizontalAlign.Right
col.HeaderText = "Agreement #"
col.DataField = "SerAgrNo"
col.ItemStyle.Font.Name = "Arial"
col.ItemStyle.Font.Size = System.Web.UI.WebControls.FontUnit.XXSmall
dgEquipment.Columns.Add(col)

End If
End Sub

Private Sub LoadGrid()

' Equipment Grid

Dim equip As New clsEquip
equip.InitDBConnection(Session("ConnectionString") )
equip.Load(Session("CustNo"), Session("LocNo"))
dgEquipment.DataSource = 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.EventArgs) 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.EventArgs) 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*******@eintelligencesoft.com> wrote in message
news:OD*************@tk2msftngp13.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**************@TK2MSFTNGP11.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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
7
by: A.M | last post by:
Hi, I want to refresh my DataGrid data on every postback. I have following code in Page_Load event, but after first page load, the DataGrid never gets refresh. Here is the code i have in...
1
by: Michelle Stone | last post by:
Hi all. I have an empty datagrid on my web form. And I add BoundDataColumn(s) to it through code. But after each postback, the columns and rows disappear. As a workabout, I tried to rebind the...
2
by: Bruce W.1 | last post by:
There's something I can't figure out. I added some javascript behavior to my datagrid, just like in this article, except in C# instead of VB: ...
2
by: Fluxray | last post by:
--Background: I have a webform including a datagrid. The datagrid is using template. Its ItemTemplate is used to display a look-up-table with labels. its EditItemTemplate is used to edit a row in...
2
by: Mark Rae | last post by:
I've inherited an ASP.NET app and have been asked to fix the following problem with a page which is used to display and/or delete records from a database. When the page loads, it displays a list of...
2
by: Jim Bancroft | last post by:
This may be a no-brainer, but I'm sure I follow what's happening here... I have a DataGrid with one DropDownList per row. If I select a few DropDown items and postback my page, I can't loop...
1
by: wh1974 | last post by:
I'm not sure if i'm heading in the right direction so would appreciate any comments on what I'm trying to do. Basically I have a DataGrid on a page which has columns whose width's I set in the...
2
by: Steve Pierce | last post by:
I am having some issues with a runtime dropdownlist in a datagrid. The issue is that I cannot get ViewState to fill the selected index of a runtime dropdown properly on postback. I do not want to...
2
by: Hardy Wang | last post by:
Hi all, We have DataGrid control in Web Form, our client requires to be able to click anywhere of a row to fire the event same as LinkBotton column is clicked. We we did in ASP.NET 1.1 is in...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.