473,883 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to handle the menu control, gridview, and postback...this is driving me nuts!

If anyone can help, I would very muchly appreciate it.

I have a main page that uses the .net 2.0 menu control with the multiview
controls as the menu choices. This works fine. One of the menu choices
dynamically loads a user control with a gridview (datagrid) control on it.
That works fine. The problem arises when the user clicks on a different
page of the gridview control---this is a paged gridview. When that happens,
the gridview goes away. I'm assuming this is happening because the
"OnPageIndexCha nging" event is causing a postback and the user control
doesn't feel like loading after that. I have tried all kinds of things to
make this work.....loadin g the control at various stages (pageload,
pagerender, etc)....to no avail. It just won't work for me.

I would appreciate any help in solving this. I am beyond giving up on it as
well. Relevant code is below:

<%@ Page Language="C#" %>
<%@ Register TagPrefix="rgp" TagName="showTi ckets" Src="showTicket s.ascx" %>

string strDBView;

protected void Page_Load(objec t sender, EventArgs e)
string strMenuLabel;

if (!IsPostBack)
for (int index = 0; index < mvTicketMan.Vie ws.Count; index++)
strMenuLabel =
mvTicketMan.Vie ws[index].ID.ToString(). Replace("vw", "").Replace("_" , " ");
mnuTicketMan.It ems.Add(new MenuItem(strMen uLabel,
index.ToString( )));
mnuTicketMan.It ems[0].Selected = true;

protected void mnuTicketMan_Me nuItemClick(obj ect sender, MenuEventArgs
Control ctrlShowTickets ;

mvTicketMan.Act iveViewIndex = Int32.Parse(e.I tem.Value);
strDBView =
mvTicketMan.Vie ws[Int32.Parse(e.I tem.Value)].ID.ToString(). Replace("vw",
"").Replace("_" , " ");

if (strDBView == "My Tickets")
ctrlShowTickets = LoadControl("sh owTickets.ascx" );
plhShowTickets. Controls.Add(ct rlShowTickets);
//((showTickets)c trlShowTickets) .DBView = strDBView;
//((showTickets)c trlShowTickets) .BindDataGrid(" Ticket_Number") ;

<asp:Menu ID="mnuTicketMa n" Width="100%" runat="server"
Orientation="Ho rizontal"
StaticEnableDef aultPopOutImage ="False"
OnMenuItemClick ="mnuTicketMan_ MenuItemClick">

<StaticMenuItem Style CssClass=MenuCe ll ItemSpacing=0px />
<StaticHoverSty le CssClass=MenuCe llHover />
<StaticSelected Style CssClass=MenuCe llSelected ItemSpacing=0px />

<asp:MultiVie w ID="mvTicketMan " runat="server" ActiveViewIndex ="0">

<%--New Ticket--%>
<asp:View ID="vwCreate_Ti cket" runat="server">
<table width="100%" height="100%" cellpadding=0 cellspacing=0>
<td class="Canvas">
<rgp:createTick et ID="rgpCreateTi cket" runat="server" />
<%--End New Ticket--%>

<%--My Tickets--%>
<asp:View ID="vwMy_Ticket s" runat="server" >
<table width="100%" height="100%" cellpadding=0 cellspacing=0>
<td class="Canvas">
<asp:PlaceHolde r ID="plhShowTick ets" runat="server" />
<%-- <rgp:showTicket s ID="rgpShowTick ets" runat="server"
<%--End My Tickets--%>
<%@ Control Language="C#" ClassName="show Tickets" Debug="true" %>
<%@ import Namespace="Syst em.Data" %>
<%@ import Namespace="MySq l.Data.MySqlCli ent" %>

<script runat="server">
MySqlConnection conMain; // main db connector
string strSortDirectio n; // toggles the sort direction

// functions
protected void Page_PreRender( object sender, EventArgs e)

public void Page_Load(Objec t source, EventArgs e)
conMain = new MySqlConnection ("db_connection _goes_here");

if (this.IsPostBac k)
//BindDataGrid("T icket_Number");

public void BindDataGrid(st ring strSortField)
strSortDirectio n = "DESC";

string sql = "sql stuff here";

MySqlDataAdapte r ad = new MySqlDataAdapte r(sql, conMain);
DataSet ds = new DataSet();


grdTickets.Data Source = ds;
grdTickets.Data Bind();
conMain.Close() ;

public void grdTickets_Page IndexChanged(Ob ject source,
GridViewPageEve ntArgs e)
grdTickets.Page Index = e.NewPageIndex;
BindDataGrid("T icket_Number");


<asp:GridView ID="grdTickets " runat="server" AllowPaging="tr ue"
OnPageIndexChan ging="grdTicket s_PageIndexChan ged" PageSize="15" >
<AlternatingRow Style BackColor="Silv er" />

Aug 9 '06 #1
0 1662

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

Similar topics

by: Bandit | last post by:
I'm populating a gridview (called docList) with document info from a network folder like so: Sub Show_Files(ByVal inputDir As String) Dim strFileNamePath As String = inputDir Dim dirInfo As DirectoryInfo = New DirectoryInfo(strFileNamePath) Dim aFiles As FileInfo() = dirInfo.GetFiles("*.doc") Array.Sort(aFiles, New CompareFileInfoEntries (CompareByOptions.LastWriteTime)) docList.DataSource = aFiles
by: Uriah | last post by:
I have a sort of critical problem that is driving users nuts. My site works fine when running over HTTP but when I switch to HTTPS, an error is generated every time a user mouses over one of the drop down menus. The error is 'This page contains both secure and nonsecure items. Do you want to display the nonsecure items?' and it is driving users nuts. There is definitely nowhere in my code that is referencing a resource over HTTP...
by: Steve Loper | last post by:
I am developing a control in ASP.NET 2.0 that is derived from GridView. This control handles paging on its own and thus renders custom paging buttons. It also add some other functionality to the GridView by overriding Render() and rendering other controls alongside the GridView’s HTML. When I click one of the pager buttons (of type ImageButton), I receive the following error: Invalid postback or callback argument. Event validation...
by: Henrik B | last post by:
I'm binding data to a DropDown through a DataSource. When I select item i get some values from database trough the SelectedIndexChanged. Values is shown in textboxes. I make changes to the values and press a button to update. After postback the oldvalues is back .... the new values is gone ... Is this a binding issue? State of dropdown works .. The selected item in dropdown is always shown after postback. This is driving me nuts .... ...
by: AG | last post by:
I have a gridview with a template column containing an imagebutton to delete the row. Under some condition I don't want the row to be deleted, so would like to remove the button. In the RowDataBound event, I can find the button, but can't seem to remove it. The code below does not throw any exception, but the button is not removed. Protected Sub gv1_RowDataBound(ByVal sender As Object, ByVal e As
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview contains a placeholder and I add the control to it, the user control is a formview bound to an object datsource. This works great until I post back the page and the user control disappears. What am I doing wrong? Regards, Chris. Protected Sub...
by: HEX | last post by:
Have a page developed w/VWD which has a Gridview control. XHTML 1.0 Transitional Doctype. Tested in VWD OK and renders in IE7 as tested. When rendered with Firefox, the Gridview is shifted far to the right. It is set as absolute and it appears Firefox is not doing the position based upon the Left: setting. Fussed with different changes to page trying to figure this out to no avail. The view source from both browsers is practically identical. The...
by: HibernatingBear | last post by:
Hello, I've been driving myself nuts trying to find a solution to this. I'm still a relative newbie to C#, and would be grateful for any helpful suggestions. I'm trying to find a way to create a gridview from a Web application to an automated powerpoint slide. If that is not possible, then reading the gridview items to a table created in powerpoint, all in C#. Have searched Google many times, results ranged from "can't be
by: Knoxy | last post by:
Hi guys, I'm using a gridview to do some inline editing. The data binds okay, its goes into edit mode and cancel okay. I'm using my own custom commandName, "save", and it picks this up okay. Don't want to use the built in "update" command. Trouble is when I go to access the form fields (textboxes etc), there isn't any data there (ie text in the textbox), I can access them though, I guess I'm missing an event somewhere. I've stripped...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.