I have a RadGrid. It contains multiple controls inside of it. One of them is a linkbutton whose clientClick triggers window.open. After the grid is loaded, I want to trigger the linkbutton's click if and only if the grid contains only one item.
I am defining the grid as follows:
In my codebehind, I am definining the ClientClick at the ItemCreated method.
I implemented the client grid databound as follows:
But this javascript method does not even get fired. Basically I have two questions at this time:
1. Am I in the right track?
2. Why is rg_DataBound not firing?
Thanks.
I am defining the grid as follows:
<
rad:RadGrid
ID
=
"rg"
runat
=
"server"
>
<
ClientSettings
>
<
ClientEvents
OnDataBound
=
"rg_DataBound"
/>
</
ClientSettings
>
<
MasterTableView
PageSize
=
"50"
DataSourceID
=
"ods"
DataKeyNames
=
"Id"
>
<
rad:GridTemplateColumn
HeaderText
=
"Name"
SortExpression
=
"a.Name"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"lblName"
runat
=
"server"
/>
</
ItemTemplate
>
</
rad:GridTemplateColumn
>
</
MasterTableView
>
</
rad:RadGrid
>
In my codebehind, I am definining the ClientClick at the ItemCreated method.
var lb = (LinkButton)e.Item.FindControl("lbName");
lb.OnClientClick = "window.open('NewPage.aspx?id=" + obj.Id + "'); return false;";
I implemented the client grid databound as follows:
function
rg_DataBound(sender, e) {
var
masterTable = $find(
'<%= rg.ClientID %>'
).get_masterTableView;
var
dataItems = masterTable.get_dataItems();
if
(masterTable.get_pageCount() == 1 && dataItems.get_count() == 1) {
var
lb = dataItems[0].findControl(
'lbName'
);
lb.click();
}
}
But this javascript method does not even get fired. Basically I have two questions at this time:
1. Am I in the right track?
2. Why is rg_DataBound not firing?
Thanks.