gridview linkbutton ,when clicked that row color should be changed

Posted by S.kanthula under Regular Expressions on 5/23/2011 | Points: 10 | Views : 5650 | Status : [Member] | Replies : 10
Hi everyone

I have taken a gridview in which i'm showing some classification info, for this classification i have taken a link button ,for the linkbutton click event i'm generating some products based on the classification id ,and these details i'\m showing in other grid ,

now what i wanted is ,when user clicks on any classification ,that row color should be changed ,

Please help me out


Thanks and regards
suman




Responses

Posted by: Lakn2 on: 5/24/2011 [Member] Starter | Points: 25

Up
0
Down
protected void lb1_click(object sender, EventArgs e)
{
bindgrid();
LinkButton btn = (LinkButton)sender;
//Get the row that contains this button
GridViewRow gvr = (GridViewRow)btn.NamingContainer ;
//Get rowindex
int rowindex = gvr.RowIndex;
GridView2.Rows[rowindex ].BackColor = Color.Red;

}

Thanks&Regards
LakshmiNarayana Nalluri.

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveen_gpk on: 5/24/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Mr.Lakn

The LinkButton is in the gridview how can you able to give click event and the code you sent is not working

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
@Praveen_gpk

You can simply add an OnClick event to the button you want to change color.
OnClick="lb1_click"

Thanks,
Debata

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveen_gpk on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks for answer its solved now..

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 5/25/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi Praveen,

Pls share the correct solution with us.

Nitha Deepak

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveen_gpk on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
The above answer is exact solution their is no changes in it,,any doubts you can ask ?

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
it is working for me i don't bother it is working for you or not if it is working use it otherwise leave it and do n't ask this type of cheap questions where can i put linkbuttin click understand

Thanks&Regards
LakshmiNarayana Nalluri.

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveen_gpk on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
its fine Mr.Lakn

Its a small confusion now i got the code how can we use it..

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
it's ok because before posting answer i checked once if it is working fine then only i give answer.but you do n't say it is not woking that is not good.

Thanks&Regards
LakshmiNarayana Nalluri.

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveen_gpk on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
i thought lb1 is label but its linkbutton1..thats it ..ok anyway thanks

S.kanthula, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response