panahinia
یک شنبه 16 اسفند 1394, 08:44 صبح
سلام و خسته نباشید
دوستان من می خوام در گریدویو بعد از کلیک بر روی دکمه ی ویرایش صفحه ی ویرایش در یک پنجره ی جدید باز شود ، کدش رو به این صورت نوشتم ولی خطا میده
protected void Grcat_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataR ow)
{
LinkButton btn = (LinkButton)(e.Row.FindControl("linkbtnedit"));
btn.Attributes.Add("OnClick", "target='_blank';");
}
}
__________________________________________________ _________
متن خطا :
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 57:
Line 58: LinkButton btn = (LinkButton)(e.Row.FindControl("linkbtnedit"));
Line 59: btn.Attributes.Add("OnClick", "target='_blank';");
_____________________________________________
قسمت aspx
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="linkbtnedit" CommandArgument="<%# Container.DataItemIndex %>" CommandName="Edit" runat="server">ویرایش</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
دوستان من می خوام در گریدویو بعد از کلیک بر روی دکمه ی ویرایش صفحه ی ویرایش در یک پنجره ی جدید باز شود ، کدش رو به این صورت نوشتم ولی خطا میده
protected void Grcat_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataR ow)
{
LinkButton btn = (LinkButton)(e.Row.FindControl("linkbtnedit"));
btn.Attributes.Add("OnClick", "target='_blank';");
}
}
__________________________________________________ _________
متن خطا :
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 57:
Line 58: LinkButton btn = (LinkButton)(e.Row.FindControl("linkbtnedit"));
Line 59: btn.Attributes.Add("OnClick", "target='_blank';");
_____________________________________________
قسمت aspx
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="linkbtnedit" CommandArgument="<%# Container.DataItemIndex %>" CommandName="Edit" runat="server">ویرایش</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>