473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Gridview Databind does not go to RowDataBound event on postback?

K B
Hi again, I've narrowed down my problem and am hoping to get some help
to get the final answer.

Gridview with dynamic child controls loads
gv1.Databind calls RowDataBound event fine

On the next postback, I use gv1.Databind in order to reload the dynamic
rows but Databind does NOT call RowDataBound event -- it skips right to
the button click event that called the postback.

Any clues please?

Thanks,
Kit
*** Sent via Developersdex http://www.developersdex.com ***
May 31 '06 #1
3 10321
"K B" <ka**********@comcast.net> wrote in message
news:ec**************@TK2MSFTNGP05.phx.gbl...
Hi again, I've narrowed down my problem and am hoping to get some help
to get the final answer.

Gridview with dynamic child controls loads
gv1.Databind calls RowDataBound event fine

On the next postback, I use gv1.Databind in order to reload the dynamic
rows but Databind does NOT call RowDataBound event -- it skips right to
the button click event that called the postback.

Any clues please?


Is the code which binds your GridView wrapped in a if(Page.IsPostBack) logic
loop...?
May 31 '06 #2
K B <ka**********@comcast.net>'s wild thoughts were released
on Tue, 30 May 2006 18:29:26 -0700 bearing the following
fruit:
Hi again, I've narrowed down my problem and am hoping to get some help
to get the final answer.

Gridview with dynamic child controls loads
gv1.Databind calls RowDataBound event fine

On the next postback, I use gv1.Databind in order to reload the dynamic
rows but Databind does NOT call RowDataBound event -- it skips right to
the button click event that called the postback.

Any clues please?


may need to see your code

Jan Hyde (VB MVP)

--
Is it fair to say that there'd be less litter in Britain if blind people were given pointed sticks?

Jun 1 '06 #3
KitB40
1
Again, on click of the Save button, postback occurs and gv1.DataBind is called. Databind should then go through the RowDataBound event but does not. Where am I going wrong?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

Session("DeptID") = 1 'FOR TESTING ONLY

'populate Process dropdown
ddlProcess_Load()

pnlJobForm.Visible = False
btnSave.Visible = False

Else 'not is postback
If pnlJobForm.Visible = True Then
BindData()
End If

End If

End Sub

Protected Sub ddlProcess_Load()
'populate Process dropdown (where Process has ControlFormReq = true)
standard code here
End Sub

Protected Sub ddlProcess_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlProcess.SelectedIndexChanged
'populate JobRef dropdown
End Sub

Protected Sub ddlJobRef_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlJobRef.SelectedIndexChanged
Session("JobID") = ddlJobRef.SelectedValue
Session("JobRef") = ddlJobRef.SelectedItem.Text
GetDataSet()
End Sub

Private Sub GetDataSet()

Dim iProcessID, iJobID As Integer
iProcessID = Session("ProcessID")
iJobID = Session("JobID")

'stored proc will check to see if any answers exist (return 0),
'if no answers, will return questions only (return 1)
Dim db As SqlDatabase = New SqlDatabase(sConn)
Dim cmd As DbCommand = db.GetStoredProcCommand("BD_GetControlData")
db.AddInParameter(cmd, "@iProcessID", SqlDbType.Int, iProcessID)
db.AddInParameter(cmd, "@iJobID", SqlDbType.Int, iJobID)
Dim ds As DataSet
ds = db.ExecuteDataSet(cmd)

Dim iCount As Integer = ds.Tables(0).Rows.Count
If iCount < 1 Then
lblMsg.Text = "No control form questions available for this Process."
lblMsg.Visible = True
pnlJobForm.Visible = False
lblJobRef.Visible = False
btnSave.Visible = False
Exit Sub
Else
Session("Questions") = ds
pnlJobForm.Visible = True
btnSave.Visible = True
lblJobRef.Text = "JOB REF: " + Session("JobRef")
lblJobRef.Visible = True
BindData()

'check for existing control form answers
cmd = db.GetStoredProcCommand("BD_GetNewControlForm")
db.AddInParameter(cmd, "@iProcessID", SqlDbType.Int, iProcessID)
db.AddInParameter(cmd, "@iJobID", SqlDbType.Int, iJobID)
ds.Clear()
ds = db.ExecuteDataSet(cmd)

iCount = ds.Tables(0).Rows.Count
If iCount < 1 Then
lblMsg.Text = "NEW CONTROL FORM: Please click the SAVE button when done."
lblMsg.Visible = True
Else
lblMsg.Text = "Please click the SAVE button after making changes."
lblMsg.Visible = True
End If

End If

End Sub

Public Sub BindData()
Dim ds As DataSet
ds = Session("Questions")
ds.Tables(0).TableName = "Questions"
gv1.DataSource = ds
gv1.DataMember = "Questions"
gv1.DataBind() 'PROBLEM - DOES NOT GO TO ROWDATABOUND ON POSTBACK
End Sub

Public Sub gv1_RowDataBound(ByVal sender As System.Object, ByVal e As GridViewRowEventArgs) Handles gv1.RowDataBound

If e.Row.RowType = ListItemType.Item Or e.Row.RowType = ListItemType.AlternatingItem Then

'code that loads each row here...works great IF called
End Sub

Protected Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'this goes through the rows and saves the user entered values -- it too works fine IF the gridview does thru databind...rowdatabound method.
End Sub
Jun 1 '06 #4

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

Similar topics

0
by: sreejith.ram | last post by:
I did google & search in this group , but couldnt find any thing related to this. This is my first attempt to connect GridView to a Oracle database via SqlDataSource. I am receving error message...
0
by: Mike P | last post by:
I have a couple of columns in my gridview that I am adding formatting to in the RowDataBound event. But when I want to edit the rows when the RowDataBound event gets called, I get an error. I'm...
3
by: ryan.mclean | last post by:
Hello everyone, I'm in a bind, and I hope somebody can point me in the right direction. I have a gridview that is bound when it is not a postback. When the grid is bound, I remove the contents...
1
by: mark4asp | last post by:
I have two grid views on the page and I want them to share the same RowDataBound event. In debug mode in notice that sender and gvMandates (below) are both termed...
1
by: =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz | last post by:
I'm moving from years with the datagrid to a new project, .net 2.0, using GridView controls. Per past practice, it is often a lot easier to inject controls (or special formatting) in RowDataBound...
0
gchq
by: gchq | last post by:
Hi there Bringing a large chunk of records into a Gridview, then making a seperate database call for each record in the RowDataBound event is quite time consuming - so I have tried to launch this...
1
by: =?Utf-8?B?cmxt?= | last post by:
I have standard gridview in an updatePanel with an AJAX timer that refreshes the data every 5 seconds by calling the grids DataBind method in the tick event. This works great. However, I have a...
3
by: COHENMARVIN | last post by:
I have a sqldatasource control that uses 3 parameters. I have a gridview that depends on the sqldatasource control The 3 parameters are session variables. So in my code, I set the values of...
2
by: Ben | last post by:
Hi, Can someone explain me why the same code with the event GridView1_RowDataBound gives this error: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.