Hi,
I am using radgrid and in itemtempalte I have a dropdownlist and a label control. OnItemDatabound event I am passing the ids of dropdownlist and a label control to a javascript function. The functions finds the client ids of the dropdownlist and a label control but when I use document.getElementbyId for label control it gives me null.
Any help would be really appreciated.
Thanks
I am using radgrid and in itemtempalte I have a dropdownlist and a label control. OnItemDatabound event I am passing the ids of dropdownlist and a label control to a javascript function. The functions finds the client ids of the dropdownlist and a label control but when I use document.getElementbyId for label control it gives me null.
Any help would be really appreciated.
Thanks
function OnSelectedIndexChange(ddlTopic, lblTopic) { alert(ddlTopic); alert(lblTopic); var ddl = document.getElementById(ddlTopic); var lbl = document.getElementById(lblTopic); // The problem occurs here
alert(lbl); ddl.style.display = "none"; }<telerik:RadGrid ID="gvTopics" runat="server" Font-Names="Verdana" Font-Size="XX-Small" Skin="Outlook" EnableEmbeddedSkins="true" GridLines="Vertical" AllowSorting="true" AllowPaging="true" Width="99%" CellPadding="2" AutoGenerateColumns="False"> <MasterTableView CommandItemDisplay="Top"> <CommandItemSettings ShowAddNewRecordButton="false" /> <Columns><telerik:GridTemplateColumn SortExpression="Topic" HeaderText="Topic"> <ItemTemplate> <asp:LinkButton ID="lnkTopic" Text='<%# Bind("Topic") %>' runat="server"></asp:LinkButton> <telerik:RadToolTip ID="rttpTopics" Width="350" Height="100" HideEvent="ManualClose" TargetControlID="lnkTopic" RelativeTo="Element" Skin="Windows7" Position="TopRight" ManualClose="true" ShowEvent="OnClick" runat="server"> <table width="100%"> <tr> <td width="40%"> select topic : </td> <td> <asp:DropDownList ID="ddlTopic" runat="server" Font-Names="Verdana" Font-Size="XX-Small" ValidationGroup="selecttopic" AutoPostBack="false" /> <asp:RequiredFieldValidator ID="rfvTopic" runat="server" ErrorMessage="## please select a topic" InitialValue="- please select -" ControlToValidate="ddlTopic" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" SetFocusOnError="True" ValidationGroup="selecttopic" /> <telerik:RadTextBox ID="rtbTopicName" EmptyMessage="please enter topic name" runat="server"> </telerik:RadTextBox> <asp:Label ID="lblTopicName" Text="TopicName" Visible="false" runat="server"></asp:Label> </td> </tr> <tr> <td> </td> <td> <asp:Button ID="btnSaveTopic" CommandArgument='<%# Container.DataItem("id")%>' ValidationGroup="selecttopic" CausesValidation="true" OnClick="btnSaveTopic_Click" Text="Save" runat="server" /> </td> </tr> </table> </telerik:RadToolTip> </ItemTemplate> </telerik:GridTemplateColumn></Columns> <NoRecordsTemplate> <asp:Label ID="Label5" runat="server" Text="no topics found"></asp:Label> </NoRecordsTemplate> </MasterTableView> </telerik:RadGrid>Protected Sub gvTopics_OnItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles gvTopics.ItemDataBound If TypeOf (e.Item) Is GridDataItem Then Dim ddlTopic As DropDownList = e.Item.FindControl("ddlTopic") Dim lblTopicName As Label = e.Item.FindControl("lblTopicName") ddlTopic.Attributes.Add("onChange", "return OnSelectedIndexChange('" & ddlTopic.ClientID & "','" & lblTopicName.ClientID & "');") End Sub