473,320 Members | 1,987 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,320 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"
AutoGenerateColumns="false"
PageSize="20" DataKeyNames="ActivityID" Runat="server"
CssClass="Grid" CellSpacing="2" BorderWidth="0px" CellPadding="4"
EmptyDataText="Non available"
OnRowDataBound="gvAwarded_RowDataBound"
OnSorting="gvAwarded_Sorting">

<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" />

<PagerTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<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"
ToolTip="Previous"
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:LinkButton>
<asp:label id="CurrentPageLabel"
forecolor="White" Font-Bold="true" Width="30%"
CssClass="lblPageCurrent"
Runat="server" />
<asp:HiddenField ID="txtPageIndex" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</PagerTemplate>

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

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 =
PensionWatch.StyleCodeToWord(e.Row.Cells[5].Text);
}
if (e.Row.RowType == DataControlRowType.Pager)
{
DropDownList pageList =
(DropDownList)e.Row.Cells[0].FindControl("ddlPager");
Label pageLabel =
(Label)e.Row.Cells[0].FindControl("CurrentPageLabel");

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;
pageList.Items.Add(item);
}
int currentPage = gvAwarded.PageIndex + 1;
pageLabel.Text = "Page " + currentPage.ToString() + " of " +
gvAwarded.PageCount.ToString();
}

Mar 26 '07 #1
1 2687
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)
{
cmdMandatewire.Attributes.Add("onmouseover",
"MenuButtonIn(this);");
cmdMandatewire.Attributes.Add("onmouseout",
"MenuButtonOut(this);");
if (!Page.IsPostBack)
{
LoadData();
Session["SortExpression"] = "EntryDate";
Session["SortDirection"] = "DESC";
}
//else
// BindGridView();
}

Mar 26 '07 #2

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

Similar topics

2
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...
0
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,...
0
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"...
0
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...
3
by: Jon Paal | last post by:
this text keeps showing up in my gridview dropdownlist "System.Data.DataRowView" How do I prevent this problem ?
0
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...
1
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"...
3
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...
0
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...
2
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
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.