piya p

piya p

  • NA
  • 84
  • 47.9k

How to increment item.ItemIndex by 1

Apr 16 2014 6:23 AM
n my application. I am adding datalist and and there is image button inside it.

when user click on any image button he should redirect to next page acccording to selected index.

I am using following code on button click event to get index of that button

ImageButton imgbtn = (ImageButton)sender;
DataListItem item = (DataListItem)imgbtn.NamingContainer;
// ImageButton tb = (ImageButton)item.FindControl("ImageButton1");

//DataListItem item = (DataListItem)imgbtn.Parent;
int index = item.ItemIndex;

but by using it index is incrementing by multiple of 2.

e.g

for 1st image it is 0,

for 2nd image it is 2,

for 3rdimage it is 4 and so on..

How to incement it by 1 ?




Answers (1)