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

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 1236
"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

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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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
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...

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.