Monday, December 18, 2023

Telerik Grid ASP.NET itemdatabound datafiled with linkbutton

aspx page

<telerik:RadGrid ID="radGrdDraftPreliminaryEnquiry" runat="server" AllowPaging="True" AllowCustomPaging="True" AllowSorting="True" CellSpacing="0" CssClass="uk-table uk-table-hover" HeaderStyle-ForeColor="#FFFFFF" HeaderStyle-BackColor="#8E8B8B" OnPageIndexChanged="radGrdDraftPreliminaryEnquiry_PageIndexChanged" OnPageSizeChanged="radGrdDraftPreliminaryEnquiry_PageSizeChanged"  HeaderStyle-Font-Names="Open Sans" OnItemCommand="radGrdDraftPreliminaryEnquiry_ItemCommand" HeaderStyle-Font-Size="Smaller" EnableEmbeddedSkins="True" EnableEmbeddedBaseStylesheet="True"  OnItemDataBound="radGrdDraftPreliminaryEnquiry_ItemDataBound">


aspx.cs


 protected void radGrdDraftPreliminaryEnquiry_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

        {

            if (e.Item is GridDataItem)// to access a row

            {

                GridDataItem item = (GridDataItem)e.Item;

                Int64 preEnqID = (Int64)DataBinder.Eval(item.DataItem, "preliminaryenquiryid");

                //var preEnqId = DataBinder.Eval(item.DataItem, "preliminaryEnquiryID") == null ? 0 : (long)DataBinder.Eval(item.DataItem, "Priority");

                LinkButton lnkgrdDraftPreliminaryEnquirySelect = (LinkButton)item.FindControl("lnkgrdDraftPreliminaryEnquirySelect");

                //lnkgrdDraftPreliminaryEnquirySelect.PostBackUrl = "PreliminaryEnquiry.aspx?ReferenceId=" + referenceid + "&ReferenceType=195";

                PreliminaryEnquiryId = preEnqID;

                lnkgrdDraftPreliminaryEnquirySelect.PostBackUrl = "PreliminaryEnquiryMigration.aspx? ReferenceId = " + CryptologyFunctions.Encrypt(PreliminaryEnquiryId) + " & ReferenceType = " + CryptologyFunctions.Encrypt(Convert.ToInt64(EnumLookup.ReferenceType.PreliminaryEnquiry).ToString()) + " & PreliminaryEnquiryId = " + CryptologyFunctions.Encrypt(PreliminaryEnquiryId) + " & Finalized = " + CryptologyFunctions.Encrypt("false") + " &ViewMode="+ CryptologyFunctions.Encrypt( false)+")";

            }

        }


Note:- Please use same datafield as in database and same as int or int64, int32 and datafield name is case sensitive.

No comments:

Post a Comment