473,480 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problems with client scripting invoked from DataGrid OnItemDataBoundEvent

Hello,

I have the following problem:
I have a DataGrid control on my page with a column with TextBox controls and
another one with ImageButton controls. In order to force a call to
JavaScript client-side script when ImageButton is pressed, I added the
following code to OnItemDataBoundEvent (check for Item Types not shown
here):

Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
Dim imgbtKosarica As ImageButton =
e.Item.Cells(7).FindControl("imgbtKosarica")
imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
tbKolicina.Text & "')")

"tbKolicina" is the TextBox control whose value I want to pass to JavaScript
for validation when ImageButton called "imgbtKosarica" is clicked.
JavaScript is currently just an elementary script (no validation yet) and
should simply display an alert box with the passed parameter
(tbKolicinaText) displayed when the ImageButton is clicked.

It works fine (finds the controls and calls the JavaScript) up to one final
point: the value of the TextBox (tbKolicina.text) doesn't reach the
JavaScript script. Whatever I write into the TextBox, I receive an empty
alert box. But, if I set the value for the tbKolicina.text programatically,
that value does get passed. I concluded therefore that only the initial
value reaches JavaScript.

What did I do wrong and how could I make this validation work?

Thank you in advance,
Hrvoje
Nov 17 '05 #1
11 1203
Hi

This should pass the value of tbKolicina field to the function
imgbtKosarica.Attributes.Add("onclick", "return
validacija(this.form.tbKolicina.value)")

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have the following problem:
I have a DataGrid control on my page with a column with TextBox controls and another one with ImageButton controls. In order to force a call to
JavaScript client-side script when ImageButton is pressed, I added the
following code to OnItemDataBoundEvent (check for Item Types not shown
here):

Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
Dim imgbtKosarica As ImageButton =
e.Item.Cells(7).FindControl("imgbtKosarica")
imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
tbKolicina.Text & "')")

"tbKolicina" is the TextBox control whose value I want to pass to JavaScript for validation when ImageButton called "imgbtKosarica" is clicked.
JavaScript is currently just an elementary script (no validation yet) and
should simply display an alert box with the passed parameter
(tbKolicinaText) displayed when the ImageButton is clicked.

It works fine (finds the controls and calls the JavaScript) up to one final point: the value of the TextBox (tbKolicina.text) doesn't reach the
JavaScript script. Whatever I write into the TextBox, I receive an empty
alert box. But, if I set the value for the tbKolicina.text programatically, that value does get passed. I concluded therefore that only the initial
value reaches JavaScript.

What did I do wrong and how could I make this validation work?

Thank you in advance,
Hrvoje

Nov 17 '05 #2
Vidar,

thank you for the advice.
Unfortunately, it still doesn't work - it displays error message within the
alert box: "'this.form.tbKolicina.value' is null or not an
object"....somehow it doesn't recognize it.

Hrvoje
"Vidar Petursson" <th*****@icysoft.com> wrote in message
news:OY*************@TK2MSFTNGP10.phx.gbl...
Hi

This should pass the value of tbKolicina field to the function
imgbtKosarica.Attributes.Add("onclick", "return
validacija(this.form.tbKolicina.value)")

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have the following problem:
I have a DataGrid control on my page with a column with TextBox controls

and
another one with ImageButton controls. In order to force a call to
JavaScript client-side script when ImageButton is pressed, I added the
following code to OnItemDataBoundEvent (check for Item Types not shown
here):

Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
Dim imgbtKosarica As ImageButton =
e.Item.Cells(7).FindControl("imgbtKosarica")
imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
tbKolicina.Text & "')")

"tbKolicina" is the TextBox control whose value I want to pass to

JavaScript
for validation when ImageButton called "imgbtKosarica" is clicked.
JavaScript is currently just an elementary script (no validation yet) and should simply display an alert box with the passed parameter
(tbKolicinaText) displayed when the ImageButton is clicked.

It works fine (finds the controls and calls the JavaScript) up to one

final
point: the value of the TextBox (tbKolicina.text) doesn't reach the
JavaScript script. Whatever I write into the TextBox, I receive an empty
alert box. But, if I set the value for the tbKolicina.text

programatically,
that value does get passed. I concluded therefore that only the initial
value reaches JavaScript.

What did I do wrong and how could I make this validation work?

Thank you in advance,
Hrvoje


Nov 17 '05 #3
Hi

Make sure the field is there and you have the name spelled correctly ( case
sensitive )

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Vidar,

thank you for the advice.
Unfortunately, it still doesn't work - it displays error message within the alert box: "'this.form.tbKolicina.value' is null or not an
object"....somehow it doesn't recognize it.

Hrvoje
"Vidar Petursson" <th*****@icysoft.com> wrote in message
news:OY*************@TK2MSFTNGP10.phx.gbl...
Hi

This should pass the value of tbKolicina field to the function
imgbtKosarica.Attributes.Add("onclick", "return
validacija(this.form.tbKolicina.value)")

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have the following problem:
I have a DataGrid control on my page with a column with TextBox controls
and
another one with ImageButton controls. In order to force a call to
JavaScript client-side script when ImageButton is pressed, I added the
following code to OnItemDataBoundEvent (check for Item Types not shown
here):

Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
Dim imgbtKosarica As ImageButton =
e.Item.Cells(7).FindControl("imgbtKosarica")
imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
tbKolicina.Text & "')")

"tbKolicina" is the TextBox control whose value I want to pass to

JavaScript
for validation when ImageButton called "imgbtKosarica" is clicked.
JavaScript is currently just an elementary script (no validation yet) and should simply display an alert box with the passed parameter
(tbKolicinaText) displayed when the ImageButton is clicked.

It works fine (finds the controls and calls the JavaScript) up to one

final
point: the value of the TextBox (tbKolicina.text) doesn't reach the
JavaScript script. Whatever I write into the TextBox, I receive an

empty alert box. But, if I set the value for the tbKolicina.text

programatically,
that value does get passed. I concluded therefore that only the initial value reaches JavaScript.

What did I do wrong and how could I make this validation work?

Thank you in advance,
Hrvoje



Nov 17 '05 #4
Hello and thank you, John.

As alert box shows, nothing was put in JavaScript, i.e., the source says
onclick="return validacija('')", just as if the text box was empty (no value
for the parameter). Funny, but the same source shows correct value in the
text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being the
entered number that doesn't reach the JavaScript....
Funny!

Hrvoje
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:#L**************@TK2MSFTNGP09.phx.gbl...
Hrvoje,

Take a look at the generated HTML with View Source in IE. Look to see what
was put into your JavaScript.
-- .e.
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Vidar,

thank you for the advice.
Unfortunately, it still doesn't work - it displays error message within

the
alert box: "'this.form.tbKolicina.value' is null or not an
object"....somehow it doesn't recognize it.

Hrvoje
"Vidar Petursson" <th*****@icysoft.com> wrote in message
news:OY*************@TK2MSFTNGP10.phx.gbl...
Hi

This should pass the value of tbKolicina field to the function
imgbtKosarica.Attributes.Add("onclick", "return
validacija(this.form.tbKolicina.value)")

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I have the following problem:
> I have a DataGrid control on my page with a column with TextBox controls and
> another one with ImageButton controls. In order to force a call to
> JavaScript client-side script when ImageButton is pressed, I added the > following code to OnItemDataBoundEvent (check for Item Types not shown > here):
>
> Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina") > Dim imgbtKosarica As ImageButton =
> e.Item.Cells(7).FindControl("imgbtKosarica")
> imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
> tbKolicina.Text & "')")
>
> "tbKolicina" is the TextBox control whose value I want to pass to
JavaScript
> for validation when ImageButton called "imgbtKosarica" is clicked.
> JavaScript is currently just an elementary script (no validation yet)
and
> should simply display an alert box with the passed parameter
> (tbKolicinaText) displayed when the ImageButton is clicked.
>
> It works fine (finds the controls and calls the JavaScript) up to
one final
> point: the value of the TextBox (tbKolicina.text) doesn't reach the
> JavaScript script. Whatever I write into the TextBox, I receive an

empty > alert box. But, if I set the value for the tbKolicina.text
programatically,
> that value does get passed. I concluded therefore that only the initial > value reaches JavaScript.
>
> What did I do wrong and how could I make this validation work?
>
> Thank you in advance,
> Hrvoje
>
>



Nov 17 '05 #5
I just took a quick look back at your code. You're taking the value out of
the TextBox in OnItemDataBound, but when did you put a value _into_ the
TextBox?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"vrba" <hr*****@recro.hr> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
Hello and thank you, John.

As alert box shows, nothing was put in JavaScript, i.e., the source says
onclick="return validacija('')", just as if the text box was empty (no value for the parameter). Funny, but the same source shows correct value in the
text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being the
entered number that doesn't reach the JavaScript....
Funny!

Hrvoje
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:#L**************@TK2MSFTNGP09.phx.gbl...
Hrvoje,

Take a look at the generated HTML with View Source in IE. Look to see what
was put into your JavaScript.
-- .e.
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Vidar,

thank you for the advice.
Unfortunately, it still doesn't work - it displays error message within
the
alert box: "'this.form.tbKolicina.value' is null or not an
object"....somehow it doesn't recognize it.

Hrvoje
"Vidar Petursson" <th*****@icysoft.com> wrote in message
news:OY*************@TK2MSFTNGP10.phx.gbl...
> Hi
>
> This should pass the value of tbKolicina field to the function
> imgbtKosarica.Attributes.Add("onclick", "return
> validacija(this.form.tbKolicina.value)")
>
> --
> Best Regards
> Vidar Petursson
> ==============================
> Microsoft Internet Client & Controls MVP
> ==============================
> "Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
> news:%2****************@TK2MSFTNGP10.phx.gbl...
> > Hello,
> >
> > I have the following problem:
> > I have a DataGrid control on my page with a column with TextBox

controls
> and
> > another one with ImageButton controls. In order to force a call to
> > JavaScript client-side script when ImageButton is pressed, I added

the > > following code to OnItemDataBoundEvent (check for Item Types not shown > > here):
> >
> > Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina") > > Dim imgbtKosarica As ImageButton =
> > e.Item.Cells(7).FindControl("imgbtKosarica")
> > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
> > tbKolicina.Text & "')")
> >
> > "tbKolicina" is the TextBox control whose value I want to pass to
> JavaScript
> > for validation when ImageButton called "imgbtKosarica" is clicked.
> > JavaScript is currently just an elementary script (no validation yet) and
> > should simply display an alert box with the passed parameter
> > (tbKolicinaText) displayed when the ImageButton is clicked.
> >
> > It works fine (finds the controls and calls the JavaScript) up to one > final
> > point: the value of the TextBox (tbKolicina.text) doesn't reach

the > > JavaScript script. Whatever I write into the TextBox, I receive an

empty
> > alert box. But, if I set the value for the tbKolicina.text
> programatically,
> > that value does get passed. I concluded therefore that only the

initial
> > value reaches JavaScript.
> >
> > What did I do wrong and how could I make this validation work?
> >
> > Thank you in advance,
> > Hrvoje
> >
> >
>
>



Nov 17 '05 #6
Hello John,
hm, I thought that OnItemDataBound I just wire the script and that values
could be transferred later.....obviously a mistake. I was thinking about
that but if I put my code inside OnSelectedIndexChanged event, then the page
doesn't react on the first click (because only then is the script activated)
but only when the same ImageButton is clicked for the second time....
Therefore, it seems I need the new solution.

Thank you,
Hrvoje

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
I just took a quick look back at your code. You're taking the value out of
the TextBox in OnItemDataBound, but when did you put a value _into_ the
TextBox?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"vrba" <hr*****@recro.hr> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
Hello and thank you, John.

As alert box shows, nothing was put in JavaScript, i.e., the source says
onclick="return validacija('')", just as if the text box was empty (no

value
for the parameter). Funny, but the same source shows correct value in the
text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being the entered number that doesn't reach the JavaScript....
Funny!

Hrvoje
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:#L**************@TK2MSFTNGP09.phx.gbl...
Hrvoje,

Take a look at the generated HTML with View Source in IE. Look to see what was put into your JavaScript.
-- .e.
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
> Vidar,
>
> thank you for the advice.
> Unfortunately, it still doesn't work - it displays error message within the
> alert box: "'this.form.tbKolicina.value' is null or not an
> object"....somehow it doesn't recognize it.
>
> Hrvoje
>
>
> "Vidar Petursson" <th*****@icysoft.com> wrote in message
> news:OY*************@TK2MSFTNGP10.phx.gbl...
> > Hi
> >
> > This should pass the value of tbKolicina field to the function
> > imgbtKosarica.Attributes.Add("onclick", "return
> > validacija(this.form.tbKolicina.value)")
> >
> > --
> > Best Regards
> > Vidar Petursson
> > ==============================
> > Microsoft Internet Client & Controls MVP
> > ==============================
> > "Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
> > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > Hello,
> > >
> > > I have the following problem:
> > > I have a DataGrid control on my page with a column with TextBox
controls
> > and
> > > another one with ImageButton controls. In order to force a call to > > > JavaScript client-side script when ImageButton is pressed, I added the
> > > following code to OnItemDataBoundEvent (check for Item Types not

shown
> > > here):
> > >
> > > Dim tbKolicina As TextBox =

e.Item.Cells(6).FindControl("tbKolicina")
> > > Dim imgbtKosarica As ImageButton =
> > > e.Item.Cells(7).FindControl("imgbtKosarica")
> > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
> > > tbKolicina.Text & "')")
> > >
> > > "tbKolicina" is the TextBox control whose value I want to pass
to > > JavaScript
> > > for validation when ImageButton called "imgbtKosarica" is clicked. > > > JavaScript is currently just an elementary script (no validation

yet)
> and
> > > should simply display an alert box with the passed parameter
> > > (tbKolicinaText) displayed when the ImageButton is clicked.
> > >
> > > It works fine (finds the controls and calls the JavaScript) up to
one
> > final
> > > point: the value of the TextBox (tbKolicina.text) doesn't reach

the > > > JavaScript script. Whatever I write into the TextBox, I receive

an empty
> > > alert box. But, if I set the value for the tbKolicina.text
> > programatically,
> > > that value does get passed. I concluded therefore that only the
initial
> > > value reaches JavaScript.
> > >
> > > What did I do wrong and how could I make this validation work?
> > >
> > > Thank you in advance,
> > > Hrvoje
> > >
> > >
> >
> >
>
>



Nov 17 '05 #7
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello John,
hm, I thought that OnItemDataBound I just wire the script and that values
could be transferred later.....obviously a mistake.


Nope. In OnItemDataBound you're supposed to bind data to the controls in the
item if they don't do that on their own. For instance, I have an employee
list datagrid with a Delete LinkButton in it. I use ItemDataBound to set the
JavaScript which displays the confirm dialog, and I take the opportunity to
concatenate the first and last name of the employee being deleted. I have a
HyperLink control in the same grid, and I set the NavigateUrl in the
ItemDataBound event to include the employee ID in the query string of the
URL.

So, I use it for things which are too complicated for a databinding
expression to handle, or for things where the databinding expression is
simply too complicated or ugly to look at in the .aspx file. I move it into
the .aspx.cs file where nobody needs to see it!
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #8
I understand.
But what is the solution for my problems then (a rhetorical question :-))?

Hrvoje
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:#x*************@TK2MSFTNGP10.phx.gbl...
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello John,
hm, I thought that OnItemDataBound I just wire the script and that values could be transferred later.....obviously a mistake.
Nope. In OnItemDataBound you're supposed to bind data to the controls in

the item if they don't do that on their own. For instance, I have an employee
list datagrid with a Delete LinkButton in it. I use ItemDataBound to set the JavaScript which displays the confirm dialog, and I take the opportunity to concatenate the first and last name of the employee being deleted. I have a HyperLink control in the same grid, and I set the NavigateUrl in the
ItemDataBound event to include the employee ID in the query string of the
URL.

So, I use it for things which are too complicated for a databinding
expression to handle, or for things where the databinding expression is
simply too complicated or ugly to look at in the .aspx file. I move it into the .aspx.cs file where nobody needs to see it!
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #9
Hello John,
hm, I thought that OnItemDataBound I just wire the script and that values
could be transferred later.....obviously a mistake. I was thinking about
that but if I put my code inside OnSelectedIndexChanged event, then the page
doesn't react on the first click (because only then is the script activated)
but only when the same ImageButton is clicked for the second time....
Therefore, it seems I need the new solution.

Thank you,
Hrvoje

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
I just took a quick look back at your code. You're taking the value out of
the TextBox in OnItemDataBound, but when did you put a value _into_ the
TextBox?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"vrba" <hr*****@recro.hr> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
Hello and thank you, John.

As alert box shows, nothing was put in JavaScript, i.e., the source says
onclick="return validacija('')", just as if the text box was empty (no

value
for the parameter). Funny, but the same source shows correct value in the
text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being the entered number that doesn't reach the JavaScript....
Funny!

Hrvoje
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:#L**************@TK2MSFTNGP09.phx.gbl...
Hrvoje,

Take a look at the generated HTML with View Source in IE. Look to see what was put into your JavaScript.
-- .e.
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
> Vidar,
>
> thank you for the advice.
> Unfortunately, it still doesn't work - it displays error message within the
> alert box: "'this.form.tbKolicina.value' is null or not an
> object"....somehow it doesn't recognize it.
>
> Hrvoje
>
>
> "Vidar Petursson" <th*****@icysoft.com> wrote in message
> news:OY*************@TK2MSFTNGP10.phx.gbl...
> > Hi
> >
> > This should pass the value of tbKolicina field to the function
> > imgbtKosarica.Attributes.Add("onclick", "return
> > validacija(this.form.tbKolicina.value)")
> >
> > --
> > Best Regards
> > Vidar Petursson
> > ==============================
> > Microsoft Internet Client & Controls MVP
> > ==============================
> > "Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
> > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > Hello,
> > >
> > > I have the following problem:
> > > I have a DataGrid control on my page with a column with TextBox
controls
> > and
> > > another one with ImageButton controls. In order to force a call to > > > JavaScript client-side script when ImageButton is pressed, I added the
> > > following code to OnItemDataBoundEvent (check for Item Types not

shown
> > > here):
> > >
> > > Dim tbKolicina As TextBox =

e.Item.Cells(6).FindControl("tbKolicina")
> > > Dim imgbtKosarica As ImageButton =
> > > e.Item.Cells(7).FindControl("imgbtKosarica")
> > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
> > > tbKolicina.Text & "')")
> > >
> > > "tbKolicina" is the TextBox control whose value I want to pass
to > > JavaScript
> > > for validation when ImageButton called "imgbtKosarica" is clicked. > > > JavaScript is currently just an elementary script (no validation

yet)
> and
> > > should simply display an alert box with the passed parameter
> > > (tbKolicinaText) displayed when the ImageButton is clicked.
> > >
> > > It works fine (finds the controls and calls the JavaScript) up to
one
> > final
> > > point: the value of the TextBox (tbKolicina.text) doesn't reach

the > > > JavaScript script. Whatever I write into the TextBox, I receive

an empty
> > > alert box. But, if I set the value for the tbKolicina.text
> > programatically,
> > > that value does get passed. I concluded therefore that only the
initial
> > > value reaches JavaScript.
> > >
> > > What did I do wrong and how could I make this validation work?
> > >
> > > Thank you in advance,
> > > Hrvoje
> > >
> > >
> >
> >
>
>



Nov 17 '05 #10
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello John,
hm, I thought that OnItemDataBound I just wire the script and that values
could be transferred later.....obviously a mistake.


Nope. In OnItemDataBound you're supposed to bind data to the controls in the
item if they don't do that on their own. For instance, I have an employee
list datagrid with a Delete LinkButton in it. I use ItemDataBound to set the
JavaScript which displays the confirm dialog, and I take the opportunity to
concatenate the first and last name of the employee being deleted. I have a
HyperLink control in the same grid, and I set the NavigateUrl in the
ItemDataBound event to include the employee ID in the query string of the
URL.

So, I use it for things which are too complicated for a databinding
expression to handle, or for things where the databinding expression is
simply too complicated or ugly to look at in the .aspx file. I move it into
the .aspx.cs file where nobody needs to see it!
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #11
I understand.
But what is the solution for my problems then (a rhetorical question :-))?

Hrvoje
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:#x*************@TK2MSFTNGP10.phx.gbl...
"Hrvoje Vrbanc" <hr*****@recro.hr> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello John,
hm, I thought that OnItemDataBound I just wire the script and that values could be transferred later.....obviously a mistake.
Nope. In OnItemDataBound you're supposed to bind data to the controls in

the item if they don't do that on their own. For instance, I have an employee
list datagrid with a Delete LinkButton in it. I use ItemDataBound to set the JavaScript which displays the confirm dialog, and I take the opportunity to concatenate the first and last name of the employee being deleted. I have a HyperLink control in the same grid, and I set the NavigateUrl in the
ItemDataBound event to include the employee ID in the query string of the
URL.

So, I use it for things which are too complicated for a databinding
expression to handle, or for things where the databinding expression is
simply too complicated or ugly to look at in the .aspx file. I move it into the .aspx.cs file where nobody needs to see it!
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #12

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

Similar topics

5
4581
by: Tyler Style | last post by:
Hullo - looking for a little advice here. I have a form on a page in one domain submitting to a cgi in another domain. Weirdly, on some Windows XP systems, a form on the page fails to submit/post...
55
4113
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems...
4
1533
by: - R | last post by:
Hello all. I'm new to .Net so please help me out. I have a application with several "Threads" running to observe various things. From time to time each thread need to add an log entry, which...
2
2031
by: cedced | last post by:
Hello, is it possible to access client files in VB.NET? What? I have doing that but it isn't good (VB.NET take file on pc server and not on pc client): (thanks) Dim fichier As StreamReader ...
2
1448
by: Paul | last post by:
If it's possible I would like to perform some client side actions on my Visual Basic asp.net application. An example of what I'm trying to do. I have a DATAGRID with columns ITEM, ITEMTYPE and a...
6
1934
by: rishabhshrivastava | last post by:
Hello All, I am using ASP.NET 2.0 and I am experiencing a problem using vbscript that is this script on client side is preventing the postback of my controls. I have a dropdownlist which is...
12
2833
by: SAL | last post by:
Hello, Is it possible to read a CSV from the Client, and bind my Datagrid to the data in the CSV file without uploading the file to the Server first? I have tried and in Debug mode on my...
0
7039
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
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
7037
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,...
1
6735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6895
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...
0
5326
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,...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1296
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 ...
0
176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.