Ramco Ramco

Ramco Ramco

  • 440
  • 3.4k
  • 520k

Error - Object reference not set to an instance of the object

May 21 2023 8:42 AM

Hi

In amazonLink it is showing Url but value in below line is NULL

HyperLink lnkAmazonLink = (HyperLink)e.Row.FindControl("AmazonURL");

In Table Header it is shown like this

<th scope="col">BookId</th><th scope="col">Book</th><th scope="col">ComboBookName</th><th scope="col">CoreRPL</th><th scope="col">Lexile</th><th scope="col">NumberOfPages</th><th scope="col">SessionPlanStatus</th><th scope="col">ClosingStock</th><th scope="col">AmazonURL</th><th scope="col">Hritvi  </th><th scope="col">Srini  </th><th scope="col">Remarks</th>
string amazonLink = DataBinder.Eval(e.Row.DataItem, "AmazonURL").ToString().Trim();
if (amazonLink != null)
{
    HyperLink lnkAmazonLink = (HyperLink)e.Row.FindControl("AmazonURL");
    //lnkAmazonLink.Text = "Amazon Link";
    //lnkAmazonLink.NavigateUrl = amazonLink;
    //lnkAmazonLink.Target = "_blank";
    ////////lnkAmazonLink.CssClass = "amazon-link";
}
<asp:GridView ID="grdPlanning" class="table table-bordered" runat="server" OnRowDataBound="gr_RowDataBound" OnRowCommand="grdPlanning_RowCommand" AutoGenerateColumns="true">
</asp:GridView>

Thanks


Answers (4)