473,405 Members | 2,444 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,405 software developers and data experts.

Passing parameter from textbox

Hello,

Please forgive my simple question, but i don't know the correct synatx.

From the masterpage i want to put a text in an textbox and then select an
item in the datagrid. I do know how to pass the items in the datagrid(e.g.
PLU, description, etc.) to an other (detail)page, but i don't know the
correct syntax of how to pass the textbox value to the detailpage.

I have the following code:

<asp:DataGrid id="dgrArticle" runat="server" autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<a href='ArticleDetail.aspx?debtorid=<%#textbox1.text %>&
plu=<%#DataBinder.Eval(Container.DataItem,
"PLU")%>&

description=<%#DataBinder.Eval(Container.DataItem, "DESCRIPTION")%
</a>
</ItemTemplate>
</asp:TemplateColumn
</Columns>
</asp:DataGrid>

The result is now:
http://localhost:8081/ArticleDetail....iption=SOME_DE
SCRIPTION

But must be (if textbox1.text="12345") :
http://localhost:8081/ArticleDetail....description=SO
ME_DESCRIPTION

Thanx, Cemal
Nov 18 '05 #1
7 3424
I don't know if I understand what you're asking, but, you are trying to
include the value of textbox1.text in a client side control, right? Why
don't you try to use a server side control, and redirect the page in the
OnClick event.

<asp:linkbutton id=LinkButton1 onclick='<%#
NavToURL(DataBinder.Eval(Container.DataItem, "PLU"),
DataBinder.Eval(Container.DataItem, "Description"))%>'
runat="server">LinkButton</asp:linkbutton>

Protected Sub NavToURL(ByVal PLU As String, ByVal Description As String)
Dim URL As String = "ArticleDetail.aspx?debtroid=" _
& Server.UrlEncode(Me.TextBox1.Text) _
& "&plu=" & Server.UrlEncode(PLU) & "&description=" &
Server.UrlEncode(Description)
Response.Redirect(URL)
End Sub

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
Hello,

Please forgive my simple question, but i don't know the correct synatx.

From the masterpage i want to put a text in an textbox and then select an
item in the datagrid. I do know how to pass the items in the datagrid(e.g.
PLU, description, etc.) to an other (detail)page, but i don't know the
correct syntax of how to pass the textbox value to the detailpage.

I have the following code:

<asp:DataGrid id="dgrArticle" runat="server" autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<a href='ArticleDetail.aspx?debtorid=<%#textbox1.text %>&
plu=<%#DataBinder.Eval(Container.DataItem,
"PLU")%>&

description=<%#DataBinder.Eval(Container.DataItem, "DESCRIPTION")%
</a>
</ItemTemplate>
</asp:TemplateColumn
</Columns>
</asp:DataGrid>

The result is now:
http://localhost:8081/ArticleDetail....iption=SOME_DE
SCRIPTION

But must be (if textbox1.text="12345") :
http://localhost:8081/ArticleDetail....description=SO
ME_DESCRIPTION

Thanx, Cemal

Nov 18 '05 #2
I think this is what i'm looking for, but how dows this work in an datagrid
(see examples below). I forgot to say that I don't have much experience with
ASP.NET.

By the way, what are client and server side controls and what are the
differences/when do I use them?

Thanx, Cemal

"Jared" <VB***********@email.com> wrote in message
news:10*************@corp.supernews.com...
I don't know if I understand what you're asking, but, you are trying to
include the value of textbox1.text in a client side control, right? Why
don't you try to use a server side control, and redirect the page in the
OnClick event.

<asp:linkbutton id=LinkButton1 onclick='<%#
NavToURL(DataBinder.Eval(Container.DataItem, "PLU"),
DataBinder.Eval(Container.DataItem, "Description"))%>'
runat="server">LinkButton</asp:linkbutton>

Protected Sub NavToURL(ByVal PLU As String, ByVal Description As String)
Dim URL As String = "ArticleDetail.aspx?debtroid=" _
& Server.UrlEncode(Me.TextBox1.Text) _
& "&plu=" & Server.UrlEncode(PLU) & "&description=" &
Server.UrlEncode(Description)
Response.Redirect(URL)
End Sub

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
Hello,

Please forgive my simple question, but i don't know the correct synatx.

From the masterpage i want to put a text in an textbox and then select an item in the datagrid. I do know how to pass the items in the datagrid(e.g. PLU, description, etc.) to an other (detail)page, but i don't know the
correct syntax of how to pass the textbox value to the detailpage.

I have the following code:

<asp:DataGrid id="dgrArticle" runat="server" autoGenerateColumns="False"> <Columns>
<asp:TemplateColumn>
<ItemTemplate>
<a href='ArticleDetail.aspx?debtorid=<%#textbox1.text %>&
plu=<%#DataBinder.Eval(Container.DataItem,
"PLU")%>&

description=<%#DataBinder.Eval(Container.DataItem, "DESCRIPTION")%
</a>
</ItemTemplate>
</asp:TemplateColumn
</Columns>
</asp:DataGrid>

The result is now:
http://localhost:8081/ArticleDetail....iption=SOME_DE SCRIPTION

But must be (if textbox1.text="12345") :
http://localhost:8081/ArticleDetail....description=SO ME_DESCRIPTION

Thanx, Cemal


Nov 18 '05 #3
Cemal,
First, what I mean by server side and client side controls is, a server
side control is one that posts to the server and a client control doesn't.
This may not be the correct definition, it's just what I am referring to.
That is why the <a href= will not work. The value of <a href> must be either
set when the page loads or through some scripting method. While I know the
..Net server controls do just that, I don't know how to duplicate this
behavior manually. Any of the controls listed on the WebForms toolbox band
should be server side controls.

In your datagrid control I am working under the assumption that it will have
a total of two columns, the first is PLU and the second is the description.
The PLU column will host the control that posts/redirects to the details
page. It looks like you are already using template columns, which need to
remain, at least for the PLU column. The Description column does not have to
be templated. Start by editing the template for the PLU column, Under the
ItemTemplate section drop in a LinkButton control. Set its id to "lnkPLU"
and end template editing. If your description column is templated remove it
and simply add a bound column in its place. Set the Data Field to the name
of the field that houses the data for the description column; in your
example below it looks like it should be set to DESCRIPTION. Now, in the
datagrid's ItemCommand event, write the following code, you should supply
your own error handling.

Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand
Try
Dim Item As DataGridItem = CType(e.Item, DataGridItem)
Dim URL As String
With Item
URL = "ArticleDetail.aspx?debtroid=" _
& Server.UrlEncode(Me.TextBox1.Text.Trim) _
& "&plu=" &
Server.UrlEncode(CType(.Cells(0).FindControl("lnkP LU"), LinkButton).Text) &
"&description=" & Server.UrlEncode(.Cells(1).Text)
End With
Response.Redirect(URL)
Catch ex as Exception
'Some error handling code
End Try
End Sub

I'm sure there are better ways of doing this, however, I don't know any. Pay
attention to the type conversion, a template column will hold controls,
that's why we have to do a little casting to get the value, on the other
hand, we can directly get the value of a bound column using the
cells(CellIndex).Text property.

Hope this helps,
Jared

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
I think this is what i'm looking for, but how dows this work in an datagrid
(see examples below). I forgot to say that I don't have much experience
with
ASP.NET.

By the way, what are client and server side controls and what are the
differences/when do I use them?

Thanx, Cemal

"Jared" <VB***********@email.com> wrote in message
news:10*************@corp.supernews.com...
I don't know if I understand what you're asking, but, you are trying to
include the value of textbox1.text in a client side control, right? Why
don't you try to use a server side control, and redirect the page in the
OnClick event.

<asp:linkbutton id=LinkButton1 onclick='<%#
NavToURL(DataBinder.Eval(Container.DataItem, "PLU"),
DataBinder.Eval(Container.DataItem, "Description"))%>'
runat="server">LinkButton</asp:linkbutton>

Protected Sub NavToURL(ByVal PLU As String, ByVal Description As String)
Dim URL As String = "ArticleDetail.aspx?debtroid=" _
& Server.UrlEncode(Me.TextBox1.Text) _
& "&plu=" & Server.UrlEncode(PLU) & "&description=" &
Server.UrlEncode(Description)
Response.Redirect(URL)
End Sub

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> Please forgive my simple question, but i don't know the correct synatx.
>
> From the masterpage i want to put a text in an textbox and then select an > item in the datagrid. I do know how to pass the items in the datagrid(e.g. > PLU, description, etc.) to an other (detail)page, but i don't know the
> correct syntax of how to pass the textbox value to the detailpage.
>
> I have the following code:
>
> <asp:DataGrid id="dgrArticle" runat="server" autoGenerateColumns="False"> > <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <a href='ArticleDetail.aspx?debtorid=<%#textbox1.text %>&
> plu=<%#DataBinder.Eval(Container.DataItem,
> "PLU")%>&
>
> description=<%#DataBinder.Eval(Container.DataItem, "DESCRIPTION")%
> </a>
> </ItemTemplate>
> </asp:TemplateColumn
> </Columns>
> </asp:DataGrid>
>
> The result is now:
> http://localhost:8081/ArticleDetail....iption=SOME_DE > SCRIPTION
>
> But must be (if textbox1.text="12345") :
> http://localhost:8081/ArticleDetail....description=SO > ME_DESCRIPTION
>
> Thanx, Cemal
>
>



Nov 18 '05 #4
Okay, I did evrything you said, but now i get an error message:
System.ArgumentOutOfRangeException: .......

Am i doimg something wrong? I include below the complete source for further
investigations. Please help we this?

Thanx, Cemal

<%@ Page Language="VB" Debug="TRUE" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load
dim SQLString as string="Select * from ARTICLE"
dim Conn as OleDbConnection
dim ConnectionString as string="Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb"
dim Cmdselect as OleDbCommand
dim dtrArticle as OleDbDataReader

Conn = New OleDbConnection (ConnectionString)
Conn.Open()
CmdSelect = New OleDbCommand(SQLString, Conn)
dtrArticle = CmdSelect.ExecuteReader()

While dtrArticle.Read()
dgrArticle.DataSource=dtrArticle
dgrArticle.DataBind()
End While

dtrArticle.Close()
Conn.Close()
End Sub

Private Sub ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Dim Item As DataGridItem = CType(e.Item, DataGridItem)
Dim URL As String

With Item
URL = "ArticleDetail.aspx?debtorid=" & (Me.txtDebtor.Text.Trim)
& _
"&plu=" &
Server.UrlEncode(CType(.Cells(0).FindControl("lnkP LU"), LinkButton).Text) &
_
"&description=" & Server.UrlEncode(.Cells(1).Text)
End With

Response.Redirect(URL)
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:TextBox id="txtDebtor" runat="server"
Width="100px"></asp:TextBox>
<br />
<asp:DataGrid id="dgrArticle" runat="server"
OnItemCommand="ItemCommand" autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id="lnkPLU" runat="server">
<%#DataBinder.Eval(Container.DataItem,
"PLU")%>
</asp:LinkButton>
<%#DataBinder.Eval(Container.DataItem,
"DESCRIPTION")%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</form>
</body>
</html>
Nov 18 '05 #5
Cemal,
You are close, but it looks like both you and I missed a step. The first
thing to fix is you need to add a second column, a databound column; this
column will be used for the description. The below definition should work;
this is why you were receiving the System.ArgumentOutOfRangeException, there
was only one column. Now, I forgot to tell you to bind the "Text" property
of the linkbutton to the PLU field from the datasource. You can do it a
couple of ways. If you are editing the template column you can select
lnkPLU, open the (DataBindings) editor, select "Text", choose custom binding
expression, and set the value to DataBinder.Eval(Container.DataItem, "PLU").
Alternatively, set the "Text" property of the linkbutton control as shown
below, both produce the same results, or replace your current datagrid's
definition with the one below.

<asp:DataGrid id="dgrArticle" runat="server" OnItemCommand="ItemCommand"
autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="PLU">
<ItemTemplate>
<asp:LinkButton id="lnkPLU" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "PLU")%>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="DESCRIPTION"
HeaderText="Description"></asp:BoundColumn>
</Columns>
</asp:DataGrid>

On a side note, you may have faster load times if you don't populate the
data on postbacks, unless there is a chance the data will change between the
posts and it will make a difference in the results.

Remember, the page load event will fire before the ItemCommand event so
when you click an item you are always rereading from the database and
filling the datagrid each time. In this case you probably don't need to do
this.

Try something like this in the page load event:

If Not IsPostBack Then
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Ole DB
Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb")
Conn.Open()
If Conn.State = ConnectionState.Open Then
Try
Dim Cmdselect As New OleDbCommand("SELECT * FROM ARTICLE", Conn)
dgrArticle.DataSource = Cmdselect.ExecuteReader
dgrArticle.DataBind()
Catch ex As Exception
'Error handling here
Finally
Conn.Close()
End Try
End If
End If

Jared

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Okay, I did evrything you said, but now i get an error message:
System.ArgumentOutOfRangeException: .......

Am i doimg something wrong? I include below the complete source for
further
investigations. Please help we this?

Thanx, Cemal

<%@ Page Language="VB" Debug="TRUE" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load
dim SQLString as string="Select * from ARTICLE"
dim Conn as OleDbConnection
dim ConnectionString as string="Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb"
dim Cmdselect as OleDbCommand
dim dtrArticle as OleDbDataReader

Conn = New OleDbConnection (ConnectionString)
Conn.Open()
CmdSelect = New OleDbCommand(SQLString, Conn)
dtrArticle = CmdSelect.ExecuteReader()

While dtrArticle.Read()
dgrArticle.DataSource=dtrArticle
dgrArticle.DataBind()
End While

dtrArticle.Close()
Conn.Close()
End Sub

Private Sub ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Dim Item As DataGridItem = CType(e.Item, DataGridItem)
Dim URL As String

With Item
URL = "ArticleDetail.aspx?debtorid=" & (Me.txtDebtor.Text.Trim)
& _
"&plu=" &
Server.UrlEncode(CType(.Cells(0).FindControl("lnkP LU"), LinkButton).Text)
&
_
"&description=" & Server.UrlEncode(.Cells(1).Text)
End With

Response.Redirect(URL)
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:TextBox id="txtDebtor" runat="server"
Width="100px"></asp:TextBox>
<br />
<asp:DataGrid id="dgrArticle" runat="server"
OnItemCommand="ItemCommand" autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id="lnkPLU" runat="server">
<%#DataBinder.Eval(Container.DataItem,
"PLU")%>
</asp:LinkButton>
<%#DataBinder.Eval(Container.DataItem,
"DESCRIPTION")%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</form>
</body>
</html>

Nov 18 '05 #6
Jared,
Thank you very much for your help, it works just like i wanted.
I will now analyse the code what it does, so that i understand what is
happening.
Thanx, Cemal.

"Jared" <VB***********@email.com> schreef in bericht
news:10*************@corp.supernews.com...
Cemal,
You are close, but it looks like both you and I missed a step. The first thing to fix is you need to add a second column, a databound column; this
column will be used for the description. The below definition should work;
this is why you were receiving the System.ArgumentOutOfRangeException, there was only one column. Now, I forgot to tell you to bind the "Text" property
of the linkbutton to the PLU field from the datasource. You can do it a
couple of ways. If you are editing the template column you can select
lnkPLU, open the (DataBindings) editor, select "Text", choose custom binding expression, and set the value to DataBinder.Eval(Container.DataItem, "PLU"). Alternatively, set the "Text" property of the linkbutton control as shown
below, both produce the same results, or replace your current datagrid's
definition with the one below.

<asp:DataGrid id="dgrArticle" runat="server" OnItemCommand="ItemCommand"
autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="PLU">
<ItemTemplate>
<asp:LinkButton id="lnkPLU" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "PLU")%>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="DESCRIPTION"
HeaderText="Description"></asp:BoundColumn>
</Columns>
</asp:DataGrid>

On a side note, you may have faster load times if you don't populate the
data on postbacks, unless there is a chance the data will change between the posts and it will make a difference in the results.

Remember, the page load event will fire before the ItemCommand event so
when you click an item you are always rereading from the database and
filling the datagrid each time. In this case you probably don't need to do
this.

Try something like this in the page load event:

If Not IsPostBack Then
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb")
Conn.Open()
If Conn.State = ConnectionState.Open Then
Try
Dim Cmdselect As New OleDbCommand("SELECT * FROM ARTICLE", Conn) dgrArticle.DataSource = Cmdselect.ExecuteReader
dgrArticle.DataBind()
Catch ex As Exception
'Error handling here
Finally
Conn.Close()
End Try
End If
End If

Jared

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Okay, I did evrything you said, but now i get an error message:
System.ArgumentOutOfRangeException: .......

Am i doimg something wrong? I include below the complete source for
further
investigations. Please help we this?

Thanx, Cemal

<%@ Page Language="VB" Debug="TRUE" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load
dim SQLString as string="Select * from ARTICLE"
dim Conn as OleDbConnection
dim ConnectionString as string="Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb"
dim Cmdselect as OleDbCommand
dim dtrArticle as OleDbDataReader

Conn = New OleDbConnection (ConnectionString)
Conn.Open()
CmdSelect = New OleDbCommand(SQLString, Conn)
dtrArticle = CmdSelect.ExecuteReader()

While dtrArticle.Read()
dgrArticle.DataSource=dtrArticle
dgrArticle.DataBind()
End While

dtrArticle.Close()
Conn.Close()
End Sub

Private Sub ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Dim Item As DataGridItem = CType(e.Item, DataGridItem)
Dim URL As String

With Item
URL = "ArticleDetail.aspx?debtorid=" & (Me.txtDebtor.Text.Trim) & _
"&plu=" &
Server.UrlEncode(CType(.Cells(0).FindControl("lnkP LU"), LinkButton).Text) &
_
"&description=" & Server.UrlEncode(.Cells(1).Text)
End With

Response.Redirect(URL)
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:TextBox id="txtDebtor" runat="server"
Width="100px"></asp:TextBox>
<br />
<asp:DataGrid id="dgrArticle" runat="server"
OnItemCommand="ItemCommand" autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id="lnkPLU" runat="server">
<%#DataBinder.Eval(Container.DataItem,
"PLU")%>
</asp:LinkButton>
<%#DataBinder.Eval(Container.DataItem,
"DESCRIPTION")%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</form>
</body>
</html>


Nov 18 '05 #7
Your welcome Cemal, if you don't understand what is going on let me know and
I will try to explain.
Jared

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
Jared,
Thank you very much for your help, it works just like i wanted.
I will now analyse the code what it does, so that i understand what is
happening.
Thanx, Cemal.

"Jared" <VB***********@email.com> schreef in bericht
news:10*************@corp.supernews.com...
Cemal,
You are close, but it looks like both you and I missed a step. The

first
thing to fix is you need to add a second column, a databound column; this
column will be used for the description. The below definition should
work;
this is why you were receiving the System.ArgumentOutOfRangeException,

there
was only one column. Now, I forgot to tell you to bind the "Text"
property
of the linkbutton to the PLU field from the datasource. You can do it a
couple of ways. If you are editing the template column you can select
lnkPLU, open the (DataBindings) editor, select "Text", choose custom

binding
expression, and set the value to DataBinder.Eval(Container.DataItem,

"PLU").
Alternatively, set the "Text" property of the linkbutton control as shown
below, both produce the same results, or replace your current datagrid's
definition with the one below.

<asp:DataGrid id="dgrArticle" runat="server" OnItemCommand="ItemCommand"
autoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="PLU">
<ItemTemplate>
<asp:LinkButton id="lnkPLU" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "PLU")%>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="DESCRIPTION"
HeaderText="Description"></asp:BoundColumn>
</Columns>
</asp:DataGrid>

On a side note, you may have faster load times if you don't populate the
data on postbacks, unless there is a chance the data will change between

the
posts and it will make a difference in the results.

Remember, the page load event will fire before the ItemCommand event so
when you click an item you are always rereading from the database and
filling the datagrid each time. In this case you probably don't need to
do
this.

Try something like this in the page load event:

If Not IsPostBack Then
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Ole

DB
Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb")
Conn.Open()
If Conn.State = ConnectionState.Open Then
Try
Dim Cmdselect As New OleDbCommand("SELECT * FROM ARTICLE",

Conn)
dgrArticle.DataSource = Cmdselect.ExecuteReader
dgrArticle.DataBind()
Catch ex As Exception
'Error handling here
Finally
Conn.Close()
End Try
End If
End If

Jared

"Cemal Karademir" <c.*********@zonnet.nl> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
> Okay, I did evrything you said, but now i get an error message:
> System.ArgumentOutOfRangeException: .......
>
> Am i doimg something wrong? I include below the complete source for
> further
> investigations. Please help we this?
>
> Thanx, Cemal
>
> <%@ Page Language="VB" Debug="TRUE" %>
> <%@ import Namespace="System.Data.OleDb" %>
> <script runat="server">
>
> Sub Page_Load
> dim SQLString as string="Select * from ARTICLE"
> dim Conn as OleDbConnection
> dim ConnectionString as
> string="Provider=Microsoft.Jet.OLEDB.4.0;
> Ole DB Services=-4; Data Source=C:\SmartSoft.NET\ORSDB.mdb"
> dim Cmdselect as OleDbCommand
> dim dtrArticle as OleDbDataReader
>
> Conn = New OleDbConnection (ConnectionString)
> Conn.Open()
> CmdSelect = New OleDbCommand(SQLString, Conn)
> dtrArticle = CmdSelect.ExecuteReader()
>
> While dtrArticle.Read()
> dgrArticle.DataSource=dtrArticle
> dgrArticle.DataBind()
> End While
>
> dtrArticle.Close()
> Conn.Close()
> End Sub
>
> Private Sub ItemCommand(ByVal source As Object, ByVal e As
> System.Web.UI.WebControls.DataGridCommandEventArgs )
> Dim Item As DataGridItem = CType(e.Item, DataGridItem)
> Dim URL As String
>
> With Item
> URL = "ArticleDetail.aspx?debtorid=" & (Me.txtDebtor.Text.Trim) > & _
> "&plu=" &
> Server.UrlEncode(CType(.Cells(0).FindControl("lnkP LU"), LinkButton).Text) > &
> _
> "&description=" & Server.UrlEncode(.Cells(1).Text)
> End With
>
> Response.Redirect(URL)
> End Sub
>
> </script>
> <html>
> <head>
> </head>
> <body>
> <form runat="server">
> <p>
> <asp:TextBox id="txtDebtor" runat="server"
> Width="100px"></asp:TextBox>
> <br />
> <asp:DataGrid id="dgrArticle" runat="server"
> OnItemCommand="ItemCommand" autoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:LinkButton id="lnkPLU" runat="server">
> <%#DataBinder.Eval(Container.DataItem,
> "PLU")%>
> </asp:LinkButton>
> <%#DataBinder.Eval(Container.DataItem,
> "DESCRIPTION")%>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> </p>
> </form>
> </body>
> </html>
>
>



Nov 18 '05 #8

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

Similar topics

2
by: AlexB | last post by:
I have a sub routine that performs an operation on all of the controls on an ASP.NET page using the If TypeOf..Is X statement. I want to pass the class, X, in as a parameter. Is this possible? ...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
1
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to...
1
by: freddy | last post by:
ok lets say I use the insertcommand in ado.net to insert a string from the info the user rights in a textbox. The textbox name is txtName.text do I use ('" +txtname.text +"'); or do I use a...
13
by: anonymike | last post by:
Hello, I started working with the ObjectDataSource today. I have the select, and have been working on getting the update method to work. Here is the asp code for my Data source: ...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
0
by: Phillip Vong | last post by:
Doing this in VS2005. ASPX in VB code. This image details my problem. http://ebay.philvong.com/help.jpg I have a simple FormView1 bound to a SQLDataSource1. In edit mode, Label1 is bound to a...
2
by: Geoff | last post by:
Consider the procedure Private Sub Adder(ByVal Num1 As Integer, etc. ) End Sub
5
by: teqkillah | last post by:
Good Day Guys! I have a new problem with my program. i've already created my report in crystal. within my report it has parameter (myinvoice) that the user needs to input. after that ive attached...
1
by: imtmub | last post by:
Hi All, I have mainpage (POselect.aspx). language VB In that page i have a textbox (txtPOId) and command button(Button1) When i press then button its should send the textbox value to Crystal...
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: 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
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
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...
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...
0
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...

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.