473,383 Members | 1,789 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,383 software developers and data experts.

DataItem Availability?

Hi all,

A quick question on data item availability?
See the function below. Upon clicking an button the following function is
executed.

My problem is, whenever the DataItem property is access nothing is return,
except a null exception.

Can i only use the DataItem while databind?

If so, what suggestions do you have to retrieve a db value relating to a
particular datagrid item?

Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)

'variable declarations
Dim blnCorrect As Boolean
Dim dgAnswerOptions As DataGrid

'iterate through data list items
For Each dlstItem As DataListItem In dlstAssessment.Items

'locate answer options datagrid control; store it in a local
variable
dgAnswerOptions =
CType(dlstItem.FindControl("dgAnswerOptions"),Data Grid)

'boolean variable indicating question has been answered correctly
blnCorrect = True

'iterate through data grid items
For Each dgItem As DataGridItem In dgAnswerOptions.Items

Try

Response.Write("Data Item: " &
dgItem.DataItem("is_correct"))

Catch

End Try

Next

Next

End Sub

Help appreciated!!
Adam
Nov 19 '05 #1
1 1017
Hi Adam,

Web application is different from windows application. The web control's
datasource, such as DataItem for datagrid, datalist, and repeatpter, is not
tightly bound with the control. The dataitem is only available when binding
data. Once rendering to client-side, it's gone. Hence after postback, it's
not available any more. If you want to use it, you should save it in
SessionState when being created, then retrieve it from SessionState.

HTH

Elton Wang

"Adam Knight" wrote:
Hi all,

A quick question on data item availability?
See the function below. Upon clicking an button the following function is
executed.

My problem is, whenever the DataItem property is access nothing is return,
except a null exception.

Can i only use the DataItem while databind?

If so, what suggestions do you have to retrieve a db value relating to a
particular datagrid item?

Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)

'variable declarations
Dim blnCorrect As Boolean
Dim dgAnswerOptions As DataGrid

'iterate through data list items
For Each dlstItem As DataListItem In dlstAssessment.Items

'locate answer options datagrid control; store it in a local
variable
dgAnswerOptions =
CType(dlstItem.FindControl("dgAnswerOptions"),Data Grid)

'boolean variable indicating question has been answered correctly
blnCorrect = True

'iterate through data grid items
For Each dgItem As DataGridItem In dgAnswerOptions.Items

Try

Response.Write("Data Item: " &
dgItem.DataItem("is_correct"))

Catch

End Try

Next

Next

End Sub

Help appreciated!!
Adam

Nov 19 '05 #2

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

Similar topics

4
by: Jeremy | last post by:
How can I prove uptime (or quantify downtime) on an ASP.NET 1.1 Web application (running on an IIS6 Windows Server Standard server)? What's going on here is that I'm considering the feasability...
4
by: Jeremy | last post by:
How can I prove uptime (or quantify downtime) on an ASP.NET 1.1 Web application (running on an IIS6 Windows Server Standard server)? What's going on here is that I'm considering the feasability...
15
by: Laser Lu | last post by:
Hi, all, I was tangled by the DataGridItem.DataItem property. I tried to invoke that property to get and display the contents that was bound to the currently selected row. However, an exception...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.