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