473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

LinkButton in Repeater: CommandArgument does not change value

hi. im new here and new in web programming. i was trying to put a pagination for my table, it is working fine but i wanted to change the color of the current page. i found some solution but most of them are in c# and im using vb, im not sure if my codes are correct and thus, im having problem with the commandArgument value. Im always getting "1" eventhough i already click page 2, the result Page 1 always has the properties changed. Please help. thank you in advance. By the way im using an arraylist which is bound to repeater with linkbutton.

Expand|Select|Wrap|Line Numbers
  1. <asp:Repeater ID="rptPages" runat="server">
  2.             <HeaderTemplate>
  3.                 <div style="float: left">Page&nbsp</div>
  4.             </HeaderTemplate>
  5.             <ItemTemplate>
  6.                 <a style="float: left">
  7.                     <asp:LinkButton ID="btnPage" runat="server"
  8.                         CommandName="Page" CommandArgument="<%# Container.DataItem%>">
  9.                         &nbsp<%# Container.DataItem%></asp:LinkButton>
  10.                 </a>
  11.             </ItemTemplate>
  12.         </asp:Repeater>
  13.  
  14. Protected Sub rptPages_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles rptPages.ItemDataBound
  15.  
  16.         Dim lnkPage As LinkButton
  17.         Dim strPage As Integer
  18.         strPage = PageNumber + 1
  19.         If e.Item.ItemType = ListItemType.Item Then
  20.             lnkPage = e.Item.FindControl("btnPage")
  21.             If lnkPage.CommandArgument.ToString() = strPage.ToString() Then
  22.                 lnkPage.Enabled = False
  23.                 lnkPage.ForeColor = Drawing.Color.Black
  24.             End If
  25.         End If
  26.  
  27.     End Sub
  28.  
  29.  
May 9 '14 #1
1 1785
I've fixed it. I also have to allow alternatingitem, its where the other value is. the code should be like this,

Expand|Select|Wrap|Line Numbers
  1. If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
  2.             lnkPage = e.Item.FindControl("btnPage")
  3.             If lnkPage.CommandArgument.ToString() = strPage.ToString() Then
  4.                 lnkPage.Enabled = False
  5.                 lnkPage.ForeColor = Drawing.Color.Black
  6.             End If
  7.         End If
  8.  
May 9 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tim Begin | last post by:
I am attempting to use the ThreadPool.SetMinThreads method as shown in the MSDN example code: int minWorker, minIOPort; int newWorker,newIOPort; ThreadPool.GetAvailableThreads(out minWorker, out...
1
by: Michael via .NET 247 | last post by:
I have a datagrid with the columns defined in the aspx <columns> <asp:TemplateColumn HeaderText="Hours" ItemStyle-Width="1%"ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:TextBox...
3
by: John Smith | last post by:
I'm looking into this peace of code: protected void DropDown_SelectedIndexChanged(object sender, EventArgs e) { DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as...
2
by: John Smith | last post by:
Will this line of the code: item.Cells.Text = "Some text..."; change only DataGrid visual value or it will also change value in the DataSource? How can I change value in DataSource? ...
0
by: marknoten | last post by:
Hi, we are working with XML files that can be as big as 6Mb. Some XML documents that obey to a certain condition must be duplicated where only 2 elements need to change value. I thought using...
1
by: jobs | last post by:
CommandArgument does not contain row index when command under Templatefield of- Gridview It appears CommandArgument passed to the rowcommand event does not contain row index when the command is...
1
by: PawelR | last post by:
Hi Group, In my application I have DataTable which is displayed in DataGridView via DataView: DataView myView = new DataView(myTable); myDataGridView.DataSource = myView; One column im...
45
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies...
1
by: Jafri256best | last post by:
I want to change value of a variable permanently during executing a form and want to enter the value through the text box.
4
by: mikael3432 | last post by:
hey. I wonder if anyone can help me with this one: I want to change value 21 to 210 in colum A, given there is another row that has value 10 in colum A and in both rows values in colum B, C D are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.