Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Monday, March 26, 2012

pass text to javascript function

Hello,
I found this code and I want to pass this function a value
from a dataset.

How do I do this?

<INPUT onmouseover="func()" type="button" value="Button"
<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script<INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button"
In the code behind (C#):

myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");

Eliyahu

"prav" <prav@.hotmail.com> wrote in message
news:10ca01c4d624$ae4a5410$a501280a@.phx.gbl...
> Hello,
> I found this code and I want to pass this function a value
> from a dataset.
> How do I do this?
> <INPUT onmouseover="func()" type="button" value="Button">
>
> <script type=text/javascript>
> function func()
> {
> //you could put anything here, e.g. opening a window etc.
> alert('Hi');
> }
> </script>
Eliyahu Goldin wrote:
> <INPUT runat="server" id="myButton" onmouseover="func()"
> type="button" value="Button">
> In the code behind (C#):
> myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
> text");
> Eliyahu

You might want to put quotes around that text:

String.Format("func('{0}')", "my text");

(and then you could still have problems with quotes inside the string)

Hans Kesting

pass text to javascript function

Hello,
I found this code and I want to pass this function a value
from a dataset.
How do I do this?
<INPUT onmouseover="func()" type="button" value="Button">
<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script><INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button">
In the code behind (C#):
myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");
Eliyahu
"prav" <prav@.hotmail.com> wrote in message
news:10ca01c4d624$ae4a5410$a501280a@.phx.gbl...
> Hello,
> I found this code and I want to pass this function a value
> from a dataset.
> How do I do this?
> <INPUT onmouseover="func()" type="button" value="Button">
>
> <script type=text/javascript>
> function func()
> {
> //you could put anything here, e.g. opening a window etc.
> alert('Hi');
> }
> </script>
>
Eliyahu Goldin wrote:
> <INPUT runat="server" id="myButton" onmouseover="func()"
> type="button" value="Button">
> In the code behind (C#):
> myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
> text");
> Eliyahu
>
You might want to put quotes around that text:
String.Format("func('{0}')", "my text");
(and then you could still have problems with quotes inside the string)
Hans Kesting

Saturday, March 24, 2012

Passing   in drpdown dataset

i am adding a row in dataset , in which i want to add
(space chracter for html) and then want to bind
dataset to asp.net dropdown list box. But & automatically
converted to & chracter.
Is there any way by which can be retained as it is
when dropdown throws the html part.
THanksVikram:
you need to HtmlDecode
Do something like this:
public static string DecodedSpaces(int numberOfSpaces)
{
string spaces = "";
for (int i = 0; i <= numberOfSpaces; ++i)
{
spaces += " ";
}
return HttpUtility.HtmlDecode(spaces);
}
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"Vikram" <anonymous@.discussions.microsoft.com> wrote in message
news:03ca01c515b8$25fef9c0$a501280a@.phx.gbl...
> i am adding a row in dataset , in which i want to add
> (space chracter for html) and then want to bind
> dataset to asp.net dropdown list box. But & automatically
> converted to & chracter.
> Is there any way by which can be retained as it is
> when dropdown throws the html part.
> THanks

Passing   in drpdown dataset

i am adding a row in dataset , in which i want to add
(space chracter for html) and then want to bind
dataset to asp.net dropdown list box. But & automatically
converted to & chracter.
Is there any way by which can be retained as it is
when dropdown throws the html part.

THanksVikram:
you need to HtmlDecode

Do something like this:

public static string DecodedSpaces(int numberOfSpaces)
{
string spaces = "";
for (int i = 0; i <= numberOfSpaces; ++i)
{
spaces += " ";
}
return HttpUtility.HtmlDecode(spaces);
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"Vikram" <anonymous@.discussions.microsoft.com> wrote in message
news:03ca01c515b8$25fef9c0$a501280a@.phx.gbl...
> i am adding a row in dataset , in which i want to add
> (space chracter for html) and then want to bind
> dataset to asp.net dropdown list box. But & automatically
> converted to & chracter.
> Is there any way by which can be retained as it is
> when dropdown throws the html part.
> THanks

Wednesday, March 21, 2012

Passing a Dataset from a function in a class

Hi, I have a class called Jobs. In that class is the function below..

Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Job_Title_ID",
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function

I now have a web form called Default.aspx

How can I poplulate a Datagrid or Select box from the above function?

Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?

Please help

Thanks Daren"Daren Hawes" <newsgroups@.webdesignmagic.com.au> wrote in
news:uOXyu5cVFHA.1452@.TK2MSFTNGP14.phx.gbl:

> I now have a web form called Default.aspx
> How can I poplulate a Datagrid or Select box from the above function?
> Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?

Yes exactly - but just remember to call Datagrid1.databind.

--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Passing a Dataset from a function in a class

Hi, I have a class called Jobs. In that class is the function below..
Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Job_Title_ID",
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function
I now have a web form called Default.aspx
How can I poplulate a Datagrid or Select box from the above function?
Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Please help
Thanks Daren"Daren Hawes" <newsgroups@.webdesignmagic.com.au> wrote in
news:uOXyu5cVFHA.1452@.TK2MSFTNGP14.phx.gbl:

> I now have a web form called Default.aspx
> How can I poplulate a Datagrid or Select box from the above function?
> Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Yes exactly - but just remember to call Datagrid1.databind.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]

Friday, March 16, 2012

passing a value to a hidden form field

Hi

Newbie Question:

I have a dataset called "mxdata" that has a field called "mxorder" with an integer value.

I want to increment that value by 1 and pass the new value to a hidden form field.

ie:

variablex = mxdata.mxorder + 1

<input name="ordervalue" type="hidden" id="ordervalue" value="<%# variablex %>"/
Obviously this is incorrect. Can someone show me how I would do this?why not just add it to the viewstate?, the ultimate hidden field of all time :-)

ViewState("orderValue") = mxdata.mxorder + 1

then after a postback you can retrive it like this

somevar = cint(ViewState("orderValue"))

Passing a Variable from a dataview

Hi,
I'm assigning the value of a variable(MotivateNumber) in a Dataview object
of a dataset. I get the correct value in the dataset. When I try to run the
function to get the value I get a 0. How can I pass the variable to outside
the function. It's declared outside:
Dim MotivateNumber as Integer
Sub Page_Load(sender As Object, e As EventArgs)
GetPart(42)
Page.Databind()
End Sub
Function GetPart(ByVal lessonID As Integer) As DataSet
..connection info
Dim queryString As String = "SELECT ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @dotnet.itags.org.LessonID) order
by [tblPage].[PageNumber]"
Dim dbCommand As New SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_lessonID As New SqlParameter
dbParam_lessonID.ParameterName = "@dotnet.itags.org.LessonID"
dbParam_lessonID.Value = lessonID
dbParam_lessonID.DbType = DbType.Int32
dbCommand.Parameters.Add(dbParam_lessonID)
Dim dataAdapter As New SqlDataAdapter(queryString, dbConnection)
dataAdapter.SelectCommand = dbCommand
Dim dataset as New DataSet()
dataAdapter.Fill(dataSet, "tblPages")
Dim tblPages as DataTable = dataset.Tables("tblPages")
Dim dvMotivate as New DataView(tblPages)
dvMotivate.RowFilter="Part='Motivate'"
Dim MotivateNumber=dvmotivate(0)("PageNumber")
Return dataSet
End Function
Message posted via http://www.webservertalk.comI figured it out. I was declaring the variable in the function.
Message posted via http://www.webservertalk.com

Passing a Variable from a dataview

Hi,

I'm assigning the value of a variable(MotivateNumber) in a Dataview object
of a dataset. I get the correct value in the dataset. When I try to run the
function to get the value I get a 0. How can I pass the variable to outside
the function. It's declared outside:

Dim MotivateNumber as Integer

Sub Page_Load(sender As Object, e As EventArgs)
GetPart(42)
Page.Databind()
End Sub
Function GetPart(ByVal lessonID As Integer) As DataSet
...connection info
Dim queryString As String = "SELECT ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @dotnet.itags.org.LessonID) order
by [tblPage].[PageNumber]"

Dim dbCommand As New SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_lessonID As New SqlParameter
dbParam_lessonID.ParameterName = "@dotnet.itags.org.LessonID"
dbParam_lessonID.Value = lessonID
dbParam_lessonID.DbType = DbType.Int32
dbCommand.Parameters.Add(dbParam_lessonID)

Dim dataAdapter As New SqlDataAdapter(queryString, dbConnection)
dataAdapter.SelectCommand = dbCommand

Dim dataset as New DataSet()
dataAdapter.Fill(dataSet, "tblPages")
Dim tblPages as DataTable = dataset.Tables("tblPages")

Dim dvMotivate as New DataView(tblPages)
dvMotivate.RowFilter="Part='Motivate'"
Dim MotivateNumber=dvmotivate(0)("PageNumber")

Return dataSet
End Function

--
Message posted via http://www.dotnetmonster.comI figured it out. I was declaring the variable in the function.

--
Message posted via http://www.dotnetmonster.com