Samy,
Use the OnItemDatabound event of the datagrid, then in that event, identify
when an actual datarow is being bound, get the button object and cast it as
a button, and finally add your attribute. It would look something like this:
1.. Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
2.. Try
3.. Dim itemType As ListItemType = e.Item.ItemType
4..
5.. If ((itemType = ListItemType.Pager) Or (itemType =
ListItemType.Header) Or (itemType = ListItemType.Footer)) Then
6.. Return
7.. Else
8.. '---You'll have to change the code that get's the link button to
reflect the proper zero based column index and control index:
9.. Dim button As LinkButton = CType(e.Item.Cells(3).Controls(0),
LinkButton)
10.. e.Item.Attributes.Add("onClick", "javascript
:[your script here];")
11.. End If
12.. Catch ex As Exception
13.. '---Handle Exception
14.. End Try
15.. End Sub
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Samy" <sa************@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi There,
I have a label in a datagrid which I make it a input type = radio in
ItemDataBound so that radio buttons are shown in the datagrid.
This is how I have it...
ASPX...
<asp:Label ID="_selectedRBtn" Runat="server"></asp:Label>
ASPX.CS
Label _selectedProfile = (Label)
e.Item.Cells[0].FindControl("_selectedRBtn");
_selectedProfile.Text = "<input type=radio name='RBtnSelection' value="
+ (int)this._constraints.DataKeys[e.Item.ItemIndex] + ">";
And I check the
if(Request.Form["RBtnSelection"] != null)
{
int SelectedID = int.Parse(Request.Form["RBtnSelection"]);
}
to retrieve the Id selected..
I have a delete button which when clicked should pop up a confirmation
pop up and then only delete the particular row...I am unable to figure
out when and where I have to add the onclick attribute for it....like.
this._deleteBtn.Attributes.Add("onclick", "return Confirm_Delete();");
Can somebody please suggest me how to do this??
Thanks a lot.