Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts

Thursday, March 29, 2012

Pop Ups

Hi

I am using a popup, I launch the popup from a form, the user then choses an item on the popup, which is put into a session variable and then another form is launched. This works OK except the original form which launched the popup is still open how do I close it when the popup is launch. I use the code below to launch the popup

Dim sTempAsString

sTemp = "<script>window.open('LPopUpContractor.aspx',null,'top=150,left=250,height=150,width=450,status=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=no');</script>"

Response.Write(sTemp)

Response.Flush()

Thanks

Louisa

Hi,
you can close the form from its container window,
<!-- Put this script in MyMainForm.aspx -->
<script type="text/javascript">
window.open('myPopupForm.aspx');
window.close();
</script>

or let the popup close the window that launched it,
<!-- Put this script in myPopupForm.aspx -->
<script type="text/javascript">
if(window.opener) {
window.opener.close();
}
</script>

This works brillantly, but I now get a popup before mine saying:

The Web page you are viewing is trying to close the window

Do you want to close this window?

I click on the yes and my popup appears, how do I get rid of the error msg popup?

Thanks

Louisa


Hi,
it is not an error message popup, it is an Internet Explorer security setting that prevents a script to close a window that wasn't opened by the script itself, without the user permission... well, it seems that a workaround exists for Internet Explorer, just try to set the window.opener property to some value. For example
<script type="text/javascript">
window.opener = this;
window.open('myPopup.aspx');
window.close();
</script>

but I'm not sure it will work on all browsers.


Hi,

The above doesn't seem to work for me as it just puts the pages into a loop, can I not close a previous page from the page load of the new page, when the new page is fully loaded?

Thanks

Louisa


Hi,
I don't know if a workaround exists for the security popup. Try to post this question in theClient Side Web Develoment section of these forums.

a little discussion about that same pop-up

http://forums.asp.net/962609/ShowPost.aspx


Hi,
thanks for posting the link, onewisehobbit.

Monday, March 26, 2012

Populate a dropdown list with a variable from a Querystring

Hi,

I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the querystring but I'm not sure
how to pass that value. I get the error that IntCourseID is not declared in:

<asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
DataSource="<%# GetLessons(IntCourseID) %>"

I tried moving the querystring outside the page load but that didn't work:

This is the code I have:

<%@dotnet.itags.org. Page Language="VB" Debug="true" validaterequest="false" %
<script runat="server"
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack = False Then
Dim IntCourseID as Integer
IntCourseID = Request.QueryString( "CourseID" )

End If
End Sub

Function GetLessons(ByVal courseID As Integer) As
System.Data.IDataReader
Dim connectionString As String = "server='(local)';
trusted_connection=true; database='xx'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)

Dim queryString As String = "SELECT [tblLesson].[LessonID],
[tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
"[tblLesson].[CourseID] = @dotnet.itags.org.CourseID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_courseID As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseID.ParameterName = "@dotnet.itags.org.CourseID"
dbParam_courseID.Value = courseID
dbParam_courseID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseID)

dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

Return dataReader
End Function

Sub addButton_Click(sender As Object, e As EventArgs)
Response.Redirect("selectPage.aspx")
End Sub

</script>
<html>
<head>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:DropDownList id="fLessonID" runat="server"
DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
DataTextField="LessonTitle"></asp:DropDownList>
<asp:Button id="addButton" onclick="addButton_Click" runat="server"
Text="Next"></asp:Button
</form>
</body>
</html
Thanks for any help

--
Message posted via http://www.dotnetmonster.comHi Jim,

I understood your probleim in the following way after reading your code...

You have a Integer Variable (IntCourseID) in your code behind fi.e...and you
want to use that value in your .aspx page. Am I right...?

If I'm right...then solution for your problem is...

Have a hidden control...and assign your querystring value (CourseId) to the
value of the hidden control. Now you can use that control in your .aspx page
code, to bind with the ddl.

Cheers,

Jerome. M

"Jim via DotNetMonster.com" wrote:

> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not sure
> how to pass that value. I get the error that IntCourseID is not declared in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click" runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.dotnetmonster.com
Hello
Dear Jim!
First the problem with your code is that you are declaring a Variable in
pageload event "IntCourseID" that will be destroyed when this event will
reach its end.
First Declare this variable in the GetLessons function
IntCourseID = Request.QueryString( "CourseID" )
so that this variable with its value can be accessed.

Regards
Malik Asif
ASP.NET,VB.NET

"Jim via DotNetMonster.com" <forum@.DotNetMonster.com> wrote in message
news:8596ac9543c84e2e8aad88fcc163c277@.DotNetMonste r.com...
> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not
sure
> how to pass that value. I get the error that IntCourseID is not declared
in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click"
runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.dotnetmonster.com

Populate a dropdown list with a variable from a Querystring

Hi,
I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the querystring but I'm not sure
how to pass that value. I get the error that IntCourseID is not declared in:
<asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
DataSource="<%# GetLessons(IntCourseID) %>"
I tried moving the querystring outside the page load but that didn't work:
This is the code I have:
<%@dotnet.itags.org. Page Language="VB" Debug="true" validaterequest="false" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack = False Then
Dim IntCourseID as Integer
IntCourseID = Request.QueryString( "CourseID" )
End If
End Sub
Function GetLessons(ByVal courseID As Integer) As
System.Data.IDataReader
Dim connectionString As String = "server='(local)';
trusted_connection=true; database='xx'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [tblLesson].[LessonID],
[tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
"[tblLesson].[CourseID] = @dotnet.itags.org.CourseID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_courseID As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseID.ParameterName = "@dotnet.itags.org.CourseID"
dbParam_courseID.Value = courseID
dbParam_courseID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseID)
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
Sub addButton_Click(sender As Object, e As EventArgs)
Response.Redirect("selectPage.aspx")
End Sub
</script>
<html>
<head>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:DropDownList id="fLessonID" runat="server"
DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
DataTextField="LessonTitle"></asp:DropDownList>
<asp:Button id="addButton" onclick="addButton_Click" runat="server"
Text="Next"></asp:Button>
</form>
</body>
</html>
Thanks for any help
Message posted via http://www.webservertalk.comHi Jim,
I understood your probleim in the following way after reading your code...
You have a Integer Variable (IntCourseID) in your code behind fi.e...and you
want to use that value in your .aspx page. Am I right...?
If I'm right...then solution for your problem is...
Have a hidden control...and assign your querystring value (CourseId) to the
value of the hidden control. Now you can use that control in your .aspx page
code, to bind with the ddl.
Cheers,
Jerome. M
"Jim via webservertalk.com" wrote:

> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not sur
e
> how to pass that value. I get the error that IntCourseID is not declared i
n:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionString)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click" runat="server
"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.webservertalk.com
>
Hello
Dear Jim!
First the problem with your code is that you are declaring a Variable in
pageload event "IntCourseID" that will be destroyed when this event will
reach its end.
First Declare this variable in the GetLessons function
IntCourseID = Request.QueryString( "CourseID" )
so that this variable with its value can be accessed.
Regards
Malik Asif
ASP.NET,VB.NET
"Jim via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:8596ac9543c84e2e8aad88fcc163c277@.Do
webservertalk.com...
> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not
sure
> how to pass that value. I get the error that IntCourseID is not declared
in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionString)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click"
runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.webservertalk.com

Populate datagrid from XML file using where type query

I am able to populate a datagrid from an XML variable using the
following:
Try
Dim ds As New DataSet
ds.ReadXml(New
StringReader(HttpContext.Current.Application("var").ToString))
dataMeet.DataSource = ds
dataMeet.DataBind()
Catch ex As Exception
error_email.fncErrorHandler(ex)
lblError.Text = ex.ToString
End Try
however this does not allow me to use a sql type query to select
exactly the data I want in the datagrid.
The query I am looking to achieve is actually very simple, just a
simple 'where' but I have no idea how to achieve this when binding to
an xml variable
The sql query and a sample xml file are pasted below:
select TITLE, FIRST_NAME || ' ' || LAST_NAME AS FULL_NAME, DEPT, EMAIL,
PHONE FROM DATABASE.TABLE "
WHERE MEMBERTYPE_CODE = 'MEM' ORDER BY MEMBER_ID
<NewDataSet>
<Table>
<MEMBERTYPE_CODE>OFF</MEMBERTYPE_CODE>
<LAST_NAME>Smith</LAST_NAME>
<FIRST_NAME>Harry</FIRST_NAME>
<TITLE>engineer</TITLE>
<DEPT>engineering</DEPT>
<EMAIL>harry.smith@dotnet.itags.org.email.address</EMAIL>
<PHONE>(111) 111-1111</PHONE>
</Table>
<Table>
<MEMBERTYPE_CODE>MEM</MEMBERTYPE_CODE>
<LAST_NAME>fred</LAST_NAME>
<FIRST_NAME>bloggs</FIRST_NAME>
<TITLE>Webmaster</TITLE>
<DEPT>Information Technology Services</DEPT>
<EMAIL>fred.blogs@dotnet.itags.org.email.address</EMAIL>
<PHONE>(111) 111-1112</PHONE>
</Table>
</NewDataSet>
Thank you for your timePerfect, just what I needed!
Thank you

Populate datagrid from XML file using where type query

I am able to populate a datagrid from an XML variable using the
following:

Try
Dim ds As New DataSet
ds.ReadXml(New
StringReader(HttpContext.Current.Application("var").ToString))
dataMeet.DataSource = ds
dataMeet.DataBind()
Catch ex As Exception
error_email.fncErrorHandler(ex)
lblError.Text = ex.ToString
End Try

however this does not allow me to use a sql type query to select
exactly the data I want in the datagrid.

The query I am looking to achieve is actually very simple, just a
simple 'where' but I have no idea how to achieve this when binding to
an xml variable

The sql query and a sample xml file are pasted below:

select TITLE, FIRST_NAME || ' ' || LAST_NAME AS FULL_NAME, DEPT, EMAIL,
PHONE FROM DATABASE.TABLE "
WHERE MEMBERTYPE_CODE = 'MEM' ORDER BY MEMBER_ID

<NewDataSet>
<Table>
<MEMBERTYPE_CODE>OFF</MEMBERTYPE_CODE>
<LAST_NAME>Smith</LAST_NAME>
<FIRST_NAME>Harry</FIRST_NAME>
<TITLE>engineer</TITLE>
<DEPT>engineering</DEPT>
<EMAIL>harry.smith@dotnet.itags.org.email.address</EMAIL>
<PHONE>(111) 111-1111</PHONE>
</Table>
<Table>
<MEMBERTYPE_CODE>MEM</MEMBERTYPE_CODE>
<LAST_NAME>fred</LAST_NAME>
<FIRST_NAME>bloggs</FIRST_NAME>
<TITLE>Webmaster</TITLE>
<DEPT>Information Technology Services</DEPT>
<EMAIL>fred.blogs@dotnet.itags.org.email.address</EMAIL>
<PHONE>(111) 111-1112</PHONE>
</Table>
</NewDataSet
Thank you for your timeHi gn,

You can use DataView's properties RowFilter and Sort to
perform functionality similar to 'WHERE' condition
and 'ORDER BY' in sql query. Following is sample code
snippet:

Dim dv As DataView = ds.Tables(0).DefaultView
dv.RowFilter = "MEMBERTYPE_CODE = 'MEM'"
dv.Sort = "LAST_NAME"
dataMeet.DataSource = dv
dataMeet.DataBind()

HTH

Elton Wang
elton_wang@.hotmail.com

>--Original Message--
>I am able to populate a datagrid from an XML variable
using the
>following:
> Try
> Dim ds As New DataSet
> ds.ReadXml(New
>StringReader(HttpContext.Current.Application
("var").ToString))
> dataMeet.DataSource = ds
> dataMeet.DataBind()
> Catch ex As Exception
> error_email.fncErrorHandler(ex)
> lblError.Text = ex.ToString
> End Try
>however this does not allow me to use a sql type query to
select
>exactly the data I want in the datagrid.
>The query I am looking to achieve is actually very
simple, just a
>simple 'where' but I have no idea how to achieve this
when binding to
>an xml variable
>The sql query and a sample xml file are pasted below:
>select TITLE, FIRST_NAME || ' ' || LAST_NAME AS
FULL_NAME, DEPT, EMAIL,
>PHONE FROM DATABASE.TABLE "
>WHERE MEMBERTYPE_CODE = 'MEM' ORDER BY MEMBER_ID
><NewDataSet>
> <Table>
> <MEMBERTYPE_CODE>OFF</MEMBERTYPE_CODE>
> <LAST_NAME>Smith</LAST_NAME>
> <FIRST_NAME>Harry</FIRST_NAME>
> <TITLE>engineer</TITLE>
> <DEPT>engineering</DEPT>
> <EMAIL>harry.smith@.email.address</EMAIL>
> <PHONE>(111) 111-1111</PHONE>
> </Table>
> <Table>
> <MEMBERTYPE_CODE>MEM</MEMBERTYPE_CODE>
> <LAST_NAME>fred</LAST_NAME>
> <FIRST_NAME>bloggs</FIRST_NAME>
> <TITLE>Webmaster</TITLE>
> <DEPT>Information Technology Services</DEPT>
> <EMAIL>fred.blogs@.email.address</EMAIL>
> <PHONE>(111) 111-1112</PHONE>
> </Table>
></NewDataSet>
>Thank you for your time
>.
Perfect, just what I needed!

Thank you

Saturday, March 24, 2012

Populate Session Variables from Datagrid for a specific cell

I need to know how to get a specific row/cell of data to post as a session variable - like I would with an ASP.Net table:

Dim ld_sum_tot_cty_tax As Doubl
Session("wa_tot_gal") = tbl_worksheet1.Rows(16).Cells(3).Text(

I am using VB.Net as the code behind, and populating the datagrid dynamically in a VB.Net Class Module - I am NOT connecting to an SQL database, but I do use the databind function

dtg_worksheet1.DataSource = lo_AZRM005A.get_dt_worksheet
dtg_worksheet1.DataBind(

How can I do this programmatically with the datagrid? Any help is GREATLY appreciated! Coleen

--
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/Every row of data which is bound to the grid fires the itemdatabound event.
So in its handler, you can take the appropriate action. Consider
Session["row"] = e.item.cells[0].text will store the first colum of the row
being bou nd

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
<coleenholley> wrote in message
news:%23Nx9N6d6DHA.2568@.TK2MSFTNGP10.phx.gbl...
> I need to know how to get a specific row/cell of data to post as a session
variable - like I would with an ASP.Net table:
> Dim ld_sum_tot_cty_tax As Double
> Session("wa_tot_gal") = tbl_worksheet1.Rows(16).Cells(3).Text()
> I am using VB.Net as the code behind, and populating the datagrid
dynamically in a VB.Net Class Module - I am NOT connecting to an SQL
database, but I do use the databind function:
> dtg_worksheet1.DataSource = lo_AZRM005A.get_dt_worksheet1
> dtg_worksheet1.DataBind()
> How can I do this programmatically with the datagrid? Any help is GREATLY
appreciated! Coleen
> --
> Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest
Community Website: http://www.dotnetjunkies.com/newsgroups/
Thanks - that helps, but I need to get the value from a Specific row - the data returned will ALWAYS have 17 rows - it will return one row for each County in Nevada, and there are 17 Counties. I specifically need to get the value from row (county) 16 for a session variable. Using Session["row"] = e.item.cells[7].text will store the seventh colum of the which row? How do I tell it to specifically get row 16? I REALLY need to have the functionality of Row(16).Cell(7); it is imperitive to the application we are building...any suggestions on getting the exact row number? Thanks for your help. Coleen

--
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
off the top of my head, if i didn't have the dataset already cached, i'd
collect each row and stack it into an array list. Then push that array list
into session.

Remind me again why you need to have this in a session variable (i've lost
the original thread)? It would seem to me that if you cache the entire
dataset, or datatable, then you could easily retrieve the dataset and access
the value directly. Consider:

DataSet ds = Session["Data"] as DataSet;
if(ds != null && ds.Tables[0].Rows.Count > 16)
value = ds.Tables[0].Rows[16][7].ToString();

Ofcourse, it is more memory efficient to cache a datatable or to stack just
the rows in an arraylist.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
<coleenholley> wrote in message
news:uP4atYn6DHA.1040@.TK2MSFTNGP10.phx.gbl...
> Thanks - that helps, but I need to get the value from a Specific row - the
data returned will ALWAYS have 17 rows - it will return one row for each
County in Nevada, and there are 17 Counties. I specifically need to get the
value from row (county) 16 for a session variable. Using Session["row"] =
e.item.cells[7].text will store the seventh colum of the which row? How do
I tell it to specifically get row 16? I REALLY need to have the
functionality of Row(16).Cell(7); it is imperitive to the application we are
building...any suggestions on getting the exact row number? Thanks for your
help. Coleen
> --
> Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest
Community Website: http://www.dotnetjunkies.com/newsgroups/