472,952 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DropDownList inside GridView won't fire any longer! aka - I moved a page to another web-site and now it's broke!

I moved a page to another web-site and now it's broke!

I had 5 pages in their own web-site. These pages have now been moved
to another web-site. Everything is fine except that one of the pages,
which I had trouble with in the past (i.e. same problem), is now
partly broke. The paging no longer fully works in the gridview.

The gvAwarded_RowDataBound code works to load the ddlPager with the
correct number of pages.

The lnkPagerBack, and lnkPager controls continue to work at
incrementing and decrementing the page count but the ddlPager,
DropDownList, does not even post back when I click it (i.e. in debug
mode it does not run the server event).

What have I done wrong!

PS: The PagerTemplate has now been AJAXified (but it doesn't work
without the AJAX anyhow!, so I can't see how AJAX could be an issue -
although, the new site has some AJAX and the old site (from which it
was moved) has none.).

I've put the relevant code below.
<form id="frmPensions" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:GridView ID="gvAwarded" AllowPaging="true" AllowSorting="true"
PageSize="20" DataKeyNames="ActivityID" Runat="server"
CssClass="Grid" CellSpacing="2" BorderWidth="0px" CellPadding="4"
EmptyDataText="Non available"

<AlternatingRowStyle CssClass="AlternatingRow" BackColor="#d8deEE"
VerticalAlign="Top" />
<HeaderStyle CssClass="GridHeader" BackColor="#666699"
HorizontalAlign="Left" Font-Bold="True" ForeColor="White"
Height="17px" VerticalAlign="Top" />
<RowStyle CssClass="GridRow" BackColor="White"
VerticalAlign="Top" />
<PagerStyle ForeColor="White" BackColor="#666699" Font-Bold="True"
CssClass="GridPager" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<div id="PageRow">
<asp:label id="MessageLabel" CssClass="lblPageMessage"
forecolor="White" Font-Bold="true"
text="Select a page:"
Runat="server" />
<asp:DropDownList id="ddlPager" AutoPostBack="true"
ForeColor="White" BackColor="#666699" Font-Bold="true"
OnSelectedIndexChanged="ddlPager_SelectedIndexChan ged"
Runat="server" /&nbsp;
<asp:LinkButton ID="lnkPagerBack" ForeColor="White"
runat="server" OnClick="lnkPagerBack_Click"
CssClass="lblPageArrow"< </asp:LinkButton&nbsp;
<asp:LinkButton ID="lnkPager" ForeColor="White" ToolTip="Next"
runat="server" OnClick="lnkPager_Click" CssClass="lblPageArrow">
<asp:label id="CurrentPageLabel"
forecolor="White" Font-Bold="true" Width="30%"
Runat="server" />
<asp:HiddenField ID="txtPageIndex" runat="server" />

<asp:BoundField DataField="ConsultantName" HeaderText="Consultant"
<ItemStyle Width="15%" CssClass="acol1" />
<asp:BoundField DataField="ManagerName" HeaderText="Manager"
<ItemStyle Width="15%" CssClass="acol2" />
<asp:BoundField DataField="AssetClassList" HeaderText="Asset Class"
<ItemStyle Width="15%" CssClass="acol3" />
<asp:BoundField DataField="Amount" HeaderText="Amount"
SortExpression="Amount" DataFormatString="{0:GBP ###,### m; n/a}"
<ItemStyle Width="7%" CssClass="acol4" />
<asp:BoundField DataField="PensionFundName" HeaderText="Investor"
<ItemStyle Width="20%" CssClass="acol5" />
<asp:BoundField DataField="Style" HeaderText="Style"
SortExpression="Style" >
<ItemStyle Width="8%" CssClass="acol6" />
<asp:BoundField DataField="CountryName" HeaderText="Country"
<ItemStyle Width="8%" CssClass="acol7" />
<asp:BoundField DataField="EntryDate" HeaderText="Entry Date"
SortExpression="EntryDate" HtmlEncode="False" DataFormatString ="{0:dd
MMM yyyy}">
<ItemStyle Width="11%" CssClass="acol8" />
<HeaderStyle CssClass="ahcol8" />
protected void ddlPager_SelectedIndexChanged(object sender, EventArgs
GridViewRow pagerRow = gvAwarded.BottomPagerRow;
DropDownList pageList;
if (pagerRow != null)
pageList = (DropDownList)pagerRow.Cells[0].FindControl("ddlPager");
gvAwarded.PageIndex = pageList.SelectedIndex;
protected void lnkPager_Click(object sender, EventArgs e)
protected void lnkPagerBack_Click(object sender, EventArgs e)
if(gvAwarded.PageIndex 0)

protected void gvAwarded_RowDataBound(object sender,
GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.Header)
foreach (TableCell tc in e.Row.Cells)
tc.Attributes.Add("title", "Sort");
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[5].Text =
if (e.Row.RowType == DataControlRowType.Pager)
DropDownList pageList =
Label pageLabel =

for (int i = 0; i < gvAwarded.PageCount; i++)
int pageNumber = i + 1;
ListItem item = new ListItem(pageNumber.ToString());
if (i == gvAwarded.PageIndex)
item.Selected = true;
int currentPage = gvAwarded.PageIndex + 1;
pageLabel.Text = "Page " + currentPage.ToString() + " of " +

Mar 26 '07 #1
1 2669
Apologies for the post. I have fixed it now. The problem was that I
added two lines to Page_Load() (shown below, commented out). That was
because the page was sometimes loading with no data in the GridView!,
I guess I need to deal with that some other way. The AJAX is no good
either the entire GridView needs to be AJAXified or none of it.
protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
Session["SortExpression"] = "EntryDate";
Session["SortDirection"] = "DESC";
// BindGridView();

Mar 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Ali | last post by:
I am adding a DropDownList control to my DataGrid footer template. I load my DropDownList using a function that returns an arrayList. I can see all my items in the DropDownList, but when I select...
by: keithb | last post by:
With a DropDownList in a GridView Edit Template, how can I set the SelectedIndex property so that the list initializes to the value shown in the Display template? When I set SelectedIndex to -1,...
by: dawg1998 | last post by:
I am able to populate a DropDownList control within multiple rows of a GridView with the following code: `````````````````````````````````````````````````````` <asp:GridView id="gvGridView"...
by: den 2005 | last post by:
Hi everybody, I created a Gridview with a TemplateField and there is Label control in ItemTemplate and a DropdownList control in EditItemTemplate, I was to displayed them ok when I click the...
by: Jon Paal | last post by:
this text keeps showing up in my gridview dropdownlist "System.Data.DataRowView" How do I prevent this problem ?
by: sgtmarcjones | last post by:
How do I access a dropdownlist that is nested within a Formview ItemTemplate Gridview Template? I want to see a label (lgbTimeKeep ! TextValue of ddlName dropdownlist) instead of a dropdownlist...
by: kageyone | last post by:
I have a gridview in .net 2.0 with a dropdownlist of two items - that being "active" and "inactive". <EditItemTemplate> <asp:DropDownList ID="ddlStatus" runat="server"...
by: S_K | last post by:
I have a GridView that has a DropDownList in one of the columns. When I edit and update any row I would like to grab the SelectedValue of that DropDownList when I'm in the GridView_RowUpdating...
by: baburk | last post by:
I am having dropdownlist inside gridview. When the dropdownlist selectedindex change an event should fire. What is the event for his. I also want to get the dropdownlist event fired row...
by: baburk | last post by:
I have Two DropDownList inside DataGrid or GridView, Now on Change of selection of First DropDownList, I want to fill value in second DropDownList
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.