473,714 Members | 3,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10357
"K B" <ka**********@c omcast.net> wrote in message
news:ec******** ******@TK2MSFTN GP05.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.IsPostB ack) logic
loop...?
May 31 '06 #2
K B <ka**********@c omcast.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 New Member
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.EventArg s) Handles Me.Load

If Not IsPostBack Then

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

'populate Process dropdown
ddlProcess_Load ()

pnlJobForm.Visi ble = False
btnSave.Visible = False

Else 'not is postback
If pnlJobForm.Visi ble = 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_Sele ctedIndexChange d(ByVal sender As Object, ByVal e As System.EventArg s) Handles ddlProcess.Sele ctedIndexChange d
'populate JobRef dropdown
End Sub

Protected Sub ddlJobRef_Selec tedIndexChanged (ByVal sender As Object, ByVal e As System.EventArg s) Handles ddlJobRef.Selec tedIndexChanged
Session("JobID" ) = ddlJobRef.Selec tedValue
Session("JobRef ") = ddlJobRef.Selec tedItem.Text
GetDataSet()
End Sub

Private Sub GetDataSet()

Dim iProcessID, iJobID As Integer
iProcessID = Session("Proces sID")
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(sCo nn)
Dim cmd As DbCommand = db.GetStoredPro cCommand("BD_Ge tControlData")
db.AddInParamet er(cmd, "@iProcessI D", SqlDbType.Int, iProcessID)
db.AddInParamet er(cmd, "@iJobID", SqlDbType.Int, iJobID)
Dim ds As DataSet
ds = db.ExecuteDataS et(cmd)

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

'check for existing control form answers
cmd = db.GetStoredPro cCommand("BD_Ge tNewControlForm ")
db.AddInParamet er(cmd, "@iProcessI D", SqlDbType.Int, iProcessID)
db.AddInParamet er(cmd, "@iJobID", SqlDbType.Int, iJobID)
ds.Clear()
ds = db.ExecuteDataS et(cmd)

iCount = ds.Tables(0).Ro ws.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("Questi ons")
ds.Tables(0).Ta bleName = "Questions"
gv1.DataSource = ds
gv1.DataMember = "Questions"
gv1.DataBind() 'PROBLEM - DOES NOT GO TO ROWDATABOUND ON POSTBACK
End Sub

Public Sub gv1_RowDataBoun d(ByVal sender As System.Object, ByVal e As GridViewRowEven tArgs) Handles gv1.RowDataBoun d

If e.Row.RowType = ListItemType.It em Or e.Row.RowType = ListItemType.Al ternatingItem Then

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

Protected Sub btnSave_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSave.Click
'this goes through the rows and saves the user entered values -- it too works fine IF the gridview does thru databind...rowd atabound 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
2406
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 "OCIEnvNlsCreate failed with return code -1 but error message text was not available" Any one seen this or anything similar? Thank you in advance for all tips,suggestions,advices & helps
0
3609
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 thinking that I need some kind of statement where I check whether the grid is in editing mode before I run the code. Here is my code : protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType ==...
3
2655
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 of a cell based on criteria e.g. Protected Sub gvOffSiteHoursRequests_RowDataBound(ByVal sender As Object, _ ByVal e As
1
12189
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 {System.Web.UI.WebControls.GridView} when I add a watch and that they show more or less the same properties and methods (depending upon whether they are the same gridview). However when coding using intellisense gvMandates shows all the properties and methods available to it...
1
11238
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 (formerly ItemDataBound) than to mess with complicated templates, especially for things that are consistent across grids or columns. GridView is dumping all the nice stuff put there during a RowDataBound event. Ex: those "!" icons in outlook or...
0
1048
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 on a new thread and use a progress bar in a seperate window so that the user knows something is happening! The progress bar launches and the datacall for the gridview fires, but the RowDataBound event doesn't! I would have thought this would have...
1
5897
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 checkbox on the web page which when checked I want to hide some rows. The code that does the hiding is in the RowDataBound event where I do a bunch of other stuff. This way every time the data is updated the rows are correctly displayed or hidden....
3
1569
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 those 3 session variables, and then do a 'gridview.databind' and hope that something happens. But nothing happens - the gridview does not appear. Then I noticed that if I click on a dropdownlist that has 'autopostback' enabled, that the page...
2
2974
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 of items. Parameter name: value and not with the event GridView1_RowCreated ?
0
8713
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7957
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6638
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5961
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4730
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3160
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 we have to send another system
2
2528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.