Answered by:
gridboundcolumn onlclik event issue

Question
-
User355715116 posted
I have a gridtemplatecolumn named
<telerik:GridTemplateColumn AllowFiltering="false" DataField="PositionName" HeaderText="Position" SortExpression="PositionName" UniqueName="uc_Position"> <HeaderStyle Width="160px" /> <ItemTemplate> <asp:Label ID="lblPosition" runat="server"></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn>
and from there i am opening a new window using the label id of Itemtemplate
if (lblPosition != null && e.Item.DataItem != null) { if (((DataRowView)e.Item.DataItem).Row["PositionName"].ToString().Trim().Length == 0) { lblPosition.Text = "-"; } else { lblPosition.Text = ((DataRowView)e.Item.DataItem).Row["PositionName"].ToString(); lblPosition.Attributes["class"] = "instituteHoverStyle"; lblPosition.Attributes["onclick"] = string.Format("EditPosition({0})", positionId.Value); #region Show Comments For Position DataTable dtCommentPosition = new DataTable(); dtCommentPosition = ApplicantManager.GetCommentsByFilter(applicantId, InstituteID, (int)ApplicantCommentStatus.Employee, null, (int)CommentType.Applicant, (int)CommentColumnType.Position_Name, null, true, positionId); string commentsPosition = UtilityApp.GetComments(dtCommentPosition); if (commentsPosition.Length > 0) { item["uc_Position"].ToolTip = commentsPosition; item["uc_Position"].Attributes.Add("style", messageImage); } #endregion } }
in my others page i have used gridboundcolumn instead of gridtemplatecolumn like this
<telerik:GridBoundColumn DataField="PositionName" HeaderText="Position" UniqueName="PositionName" ItemStyle-CssClass="breakWord"> </telerik:GridBoundColumn>
so my question is how can i now grab the value of label or set the id of Position to open a new using the onclick event like the previous one that i mentioned above the way i did with gridtemplatecolumn.
Regards,
Monday, July 13, 2020 6:38 AM
Answers
-
User1535942433 posted
Hi mazharul007,
Accroding to your description and codes,since telerik is not free, I couldn't create a demo.
However,as far as I think,it is same with asp.net gridview.
So,I suggest you could try this:rotected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
GridDataItem dataItem = e.Item as GridDataItem;
Label lblPosition= dataItem["PositionName"].Control[0] as Label;
lblPosition.Attributes.Add("OnClick", string.Format("EditPosition({0})", positionId.Value);
Best regards,
Yijing Sun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 14, 2020 7:36 AM
All replies
-
User1535942433 posted
Hi mazharul007,
Accroding to your description and codes,since telerik is not free, I couldn't create a demo.
However,as far as I think,it is same with asp.net gridview.
So,I suggest you could try this:rotected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
GridDataItem dataItem = e.Item as GridDataItem;
Label lblPosition= dataItem["PositionName"].Control[0] as Label;
lblPosition.Attributes.Add("OnClick", string.Format("EditPosition({0})", positionId.Value);
Best regards,
Yijing Sun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 14, 2020 7:36 AM -
User355715116 posted
Thanks a lot yij sun
Tuesday, July 14, 2020 8:26 AM