473,472 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem injecting javascript in GridView

MJB

I have a grid view that is databound to a table with 3 columns. One
column contains a customer ID. I am trying to add a 4th unbound column
that contains a button and has a javascript onclick event. I need the
id from the cusomer id column to use my onclick event. but since my
onclick event is created using a Template Field I don't know how to get
the ID to use it in my onclick. If anyone has any suggestions I would
appreciate it.

FYI I'm doing this because I'm trying to avoid a postback. I'm trying
to use ajax to make a call to the server and fill in the customer
details in a different panel.

TIA,
Matt
Nov 10 '06 #1
1 2146
"MJB" <mb*@email.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>
I have a grid view that is databound to a table with 3 columns. One
column contains a customer ID. I am trying to add a 4th unbound column
that contains a button and has a javascript onclick event. I need the id
from the cusomer id column to use my onclick event. but since my onclick
event is created using a Template Field I don't know how to get the ID to
use it in my onclick. If anyone has any suggestions I would appreciate
it.

FYI I'm doing this because I'm trying to avoid a postback. I'm trying to
use ajax to make a call to the server and fill in the customer details in
a different panel.
At the RowDataBound callback, You can add the onclick handler and put the id
into the argument as in something like this

Panel thisPanel = (Panel)e.Row.FindControl("ID_MyPanel");
// assume you have only a panel in your template
Button thisButton = new Button();
thisButton.attributes.Add("onclick","return ButtonHandler("' +
id_from_customer_data + "'));
thisPanel.Controls.Add(thisButton);

id_from_customer_data is obtained from the same row# but another column or
from the actual dataitem if it is not in a cell as in
DataRowView drv = (DataRowView)e.Row.DataItem;
id_from_customer_data = drv["id_cust_data"].ToString();

...hth..

--
================================================== =====================
Beemer Biker joestateson at grandecom dot net
http://TipsForTheComputingImpaired.com
http://ResearchRiders.org Ask about my 99'R1100RT
================================================== =====================
Nov 10 '06 #2

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

Similar topics

0
by: googleThis | last post by:
I have a GridView control on a ASP.NET 2.0 page. I load the GridView with a SqlDataReader that gets its data from a stored procedure. Here is how the grid is defined: <asp:GridView...
2
by: Kamen | last post by:
Hello there, I try to define the properties font-size and font-bold of the pager of a gridview using the pagerstyle, but the settings are not appleyd at run time. What could be the reason for...
1
by: pApAk | last post by:
Hi, i am working at .NET Web-Application (c# codebehind) and i have placed on my web-site a GridView, aka DataGrid (that works as Server control). This GridView generated following code in...
1
by: kuangzhang | last post by:
Dear MS Gurus, I have read many posts on the Gridview pagerstyle problem but have yet to see a fix or an work around. Following is what I am experiencing: in the Aspx Page I have this <PagerStyle...
1
by: MJB | last post by:
I have a grid view that is databound to a table with 3 columns. One column contains a customer ID. I am trying to add a 4th unbound column that contains a button and has a javascript onclick...
1
by: gabe | last post by:
How do you call a client side javascript callback method after an update panel has posted back to the server? I have two update panels (A + B) with a gridview in each panel. GridView B has a...
1
by: jediknight | last post by:
I am having some problems getting the correct values from a textbox in a gridview. When I create the gridview my textboxes are initialised to zeros but the user can then updates some of these....
14
by: ofiras | last post by:
Hii everyone, I'm a web programmer, but I never understood sql injecting. All I found was that you can write "a' or 'a'='a" in the password field to try to connect without knowing the password. I...
1
Frinavale
by: Frinavale | last post by:
I'm working on an ASP.NET application using VB.NET for server side code. I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this...
1
by: raviviswanathan.81 | last post by:
Hello, So we have a webmaster who sets document.domain to some domain. After that, we try to create and inject text inside an iframe by getting the iframeID.contentDocument (or...
0
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.