Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I use Gridview and binding from database. And, i use OnRowDataBound="Gridprepack_RowBound" .
C#
protected void Gridprepack_RowBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblqty = (Label)e.Row.FindControl("lblqty1");
Label lblpriceprepack = (Label)e.Row.FindControl("lblpriceprepack");
Label lblpackprice = (Label)e.Row.FindControl("lblpackprice");
Label lblmapprice = (Label)e.Row.FindControl("lblmapprice");
Label lbladdtocart = (Label)e.Row.FindControl("lbladdtocart");
LinkButton lnkviewcart12 = (LinkButton)e.Row.FindControl("likbtn");
.
.
.
.
}


as i used LinkButton find control, my whole gridview shows just blank. But no Error ! No exception though..

once i removed this line "LinkButton lnkviewcart12 = (LinkButton)e.Row.FindControl("likbtn");" . Whole gridview shows perfectly.

why it is happening like that?

Thank you!..
Posted
Updated 25-Sep-15 18:29pm
v2
Comments
While you debug what is the value of lnkviewcart12 ?

1 solution

On Row Data bound... The Word it self has the meaning...

After the databind();
What will happening in each is control or what we want on the particular row can be control by the on row bound...

Linkbutton is just a button we doesn't bind anything on it..

You can observe, If u may use more than link button on the grid..
we doesn't say what linkbutton is to be click by means of "ID" which is used in find control..

for all linkbutton we only use..
just say (linkbutton )sender,Imagebutton(sender)....


So.....

LinkButton lnkviewcart12 = (LinkButton)e.Row.FindControl("likbtn");
is no need on row databound...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900