Hi Mike,
Welcome to the ASPNET newsgroup.
As for the adding script behavior on buttons in datagrid rows, are you
developing the page through ASP.NET 1.x or the new ASP.NET 2.0? I assume
that you're using ASP.NET 1.x(Since datagrid is mostly replaced by GridView
in 2.0). For ASP.NET 1.x, if you want to do some customization on the sub
controls(like a button) in datagrid row, I suggest you consider using
TemplateColumn since this can allow us to do much customization. And to add
client-side script behavior for a certain control in the templatecolumn,
there exists serveral approachs:
1. directly embeded the script in template through databinding
expression(if the embeded script is not too complex to handle in
databinding expression. e.g:
===========================
<asp

ataGrid id="dgGrid" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="Text" HeaderText="Text"></asp:BoundColumn>
<asp:BoundColumn DataField="Value"
HeaderText="Value"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Ops">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<INPUT type="button" value="Button" onclick='pop_up("<%#
DataBinder.Eval(Container.DataItem,"Value") %>");'/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp

ataGrid>
===============================
=======code behind========
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
ListItemCollection items = new ListItemCollection();
for(int i=0;i<10;i++)
{
items.Add("item_" + i);
}
dgGrid.DataSource = items;
dgGrid.DataBind();
}
}
===========================
In above code I bind the grid with a simple ListItemcollection. and use
some databindig expression to add the script behavior for the html button
element(let it open a modeless dialog display the certain show picture
page, by passing the userid).
2. we can use the datagrid's ItemDataBound or ItemCreated event to
programmatically locate sub controls from DataGrid Cell and do some
customization on them. e.g:
================
private void dgGrid_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
TextBox txt = e.Item.Cells[0].FindControl("txtXXX") as TextBox;
//......
}
}
====================
I use the ItemCreated event to locate a textbox control I defined in the
datagrid's column 0
Hope this helps. If there's anything unclear, please feel free to let me
know.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.