In my application there is Rad grid, in its MasterTableView, there is DetailTables, in its GridTableView's CommandItemTemplate , i have taken one LinkButton.
Problem is that I am not getting this linkbutton in ondetailtabledatabind event.
I am giving code below..
<telerik:RadGrid ID="grdExams" runat="server" ondetailtabledatabind="grdExams_DetailTableDataBind">
<GroupPanel Visible="True">
</GroupPanel>
<MasterTableView GridLines="None" DataKeyNames="ID" DataSourceID="LinqDataSource1"
CommandItemDisplay="TopAndBottom" Width="100%" Name="Examinations">
<DetailTables>
<telerik:GridTableView HierarchyLoadMode="Client" DataSourceID="LinqDataSource2" DataKeyNames="ID"
Width="100%" runat="server" CommandItemDisplay="Bottom" AllowAutomaticDeletes="true"
AllowFilteringByColumn="false" Name="Detractions">
<ParentTableRelation>
<telerik:GridRelationFields MasterKeyField="ID" DetailKeyField="ExaminationID" />
</ParentTableRelation>
<EditFormSettings>
<PopUpSettings ScrollBars="None"></PopUpSettings>
</EditFormSettings>
<CommandItemTemplate>
<asp:LinkButton ID="lnkAddDetraction" runat="server" CommandName="InitInsert" >
I want to find the above link button "lnkAddDetraction"...
Thanks.
5 Answers, 1 is accepted
Try accessing the LinkButton in the CommandItemTemplate as shown below.
CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if ((e.Item is GridCommandItem) && (e.Item.OwnerTableView.Name == "Detractions")) |
{ |
GridCommandItem cmditm = (GridCommandItem)e.Item; |
LinkButton lnkbtn = (LinkButton)cmditm.FindControl("lnkAddDetraction"); |
} |
} |
Hope this helps..
Shinu.
I want to find the linkbutton on ondetailtabledatabind event.
there i cant get e.item.. which is easy to get on Databound.
is there any other way?
Thanks...
If you would like to modify settings for the link button inside the detail table's command item, the proper place to do that are the ItemCreated or ItemDataBound events of the grid. This will ensure that the viewstate and the event lifecycle of the link button will be consistent.
More information about the ItemCreated/ItemDataBound events of RadGrid you can gather from this resource:
http://www.telerik.com/help/aspnet-ajax/grddistinguishdifferencesbetweenitemcreateditemdatabound.html
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Try setting the EventHandler for the ItemDataBound event in the aspx as shown below.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemDataBound="RadGrid1_ItemDataBound" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" > |
Thanks
Princy.
Hi,
My problem of opening rad window on click on link button of grid have solved.
Thanks alot for all your help,
I have used this code in item data bound
protected void grdExams_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
((e.Item is GridCommandItem) && (e.Item.OwnerTableView.Name == "Detractions"))
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
LinkButton lnkbtn = (LinkButton)cmditm.FindControl("lnkAddDetraction");
lnkbtn.OnClientClick =
"window.radopen('Detractions/Edit.aspx','DetractionDialog');return false;";
}
}
But now on telerik pop up i am using edit.aspx page.
in this page i am using
<radT:RadTreeView ID="tvDetractionTypes" runat="server" DataTextField="Title" DataFieldID="ID"
BeforeClientClick="handleNodeClick" DataValueField="ID" DataFieldParentID="ParentDetractionTypeID"
Skin="Office2007" DataSourceID="dsDetractionTypes" Height="150px" Width="250px"
OnNodeBound="tvDetractionTypes_NodeBound">
</radT:RadTreeView>
and in java script
<
<script type="text/javascript">
function
handleNodeClick(node)
{
//if this is a parent node, expand it and select the first child
if (node.Parent == null && node.Nodes.length > 0)
{
node.Expand();
node.TreeView.UnSelectAllNodes();
node.Nodes[0].Select();
return false;
}
// Unlock any locked sliders
SliderArrays[0][idxSliderLocked] =
false;
SliderArrays[1][idxSliderLocked] =
false;
SliderArrays[2][idxSliderLocked] =
false;
SliderArrays[3][idxSliderLocked] =
false;
// Make sliders visible
SliderArrays[0][idxSliderDisplay] =
true;
SliderArrays[1][idxSliderDisplay] =
true;
SliderArrays[2][idxSliderDisplay] =
true;
SliderArrays[3][idxSliderDisplay] =
true;
// Redraw the sliders to reflect the new default values
SliderArrays[0][idxSliderDisplayWeight] = node.Attributes[
"DefaultTech"];
SliderArrays[1][idxSliderDisplayWeight] = node.Attributes[
"DefaultEquip"];
SliderArrays[2][idxSliderDisplayWeight] = node.Attributes[
"DefaultPatient"];
SliderArrays[3][idxSliderDisplayWeight] = node.Attributes[
"DefaultProcess"];
SliderDrawTable();
// Change the default DV
var combo = <%= RecursiveFindControl("cboSeverity").ClientID %>;
var item = combo.FindItemByValue(node.Attributes["DefaultDV"]);
if (item != null) item.Select();
//Change the tooltip text
<%= RecursiveFindControl(
"lnkTip").ClientID %>.title = node.Attributes["ChangeTip"];
return true;
}
</script>
Its giving run time error in the below line "exception is thrown"
<%= RecursiveFindControl("lnkTip").ClientID %>.title = node.Attributes["ChangeTip"];
if i removed the javascript and comment the <radT:RadTreeView it gives runtime error
Cannot find a string resource with key 'ImageEditor' in App_GlobalResources/RadEditor.Tools.resx. Please, make sure that your custom localization has all needed resource strings, or copy the original localization resources from your installation folder to App_GlobalResources.
please assist