473,398 Members | 2,389 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,398 software developers and data experts.

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
"OnPageIndexChanging" 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.....loading 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:

masterpage.aspx
-------------------------------
<%@ Page Language="C#" %>
<%@ Register TagPrefix="rgp" TagName="showTickets" Src="showTickets.ascx" %>

string strDBView;

protected void Page_Load(object sender, EventArgs e)
{
string strMenuLabel;

if (!IsPostBack)
{
for (int index = 0; index < mvTicketMan.Views.Count; index++)
{
strMenuLabel =
mvTicketMan.Views[index].ID.ToString().Replace("vw", "").Replace("_", " ");
mnuTicketMan.Items.Add(new MenuItem(strMenuLabel,
index.ToString()));
}
mnuTicketMan.Items[0].Selected = true;
}
}

protected void mnuTicketMan_MenuItemClick(object sender, MenuEventArgs
e)
{
Control ctrlShowTickets;

mvTicketMan.ActiveViewIndex = Int32.Parse(e.Item.Value);
strDBView =
mvTicketMan.Views[Int32.Parse(e.Item.Value)].ID.ToString().Replace("vw",
"").Replace("_", " ");

if (strDBView == "My Tickets")
{
ctrlShowTickets = LoadControl("showTickets.ascx");
plhShowTickets.Controls.Add(ctrlShowTickets);
//((showTickets)ctrlShowTickets).DBView = strDBView;
//((showTickets)ctrlShowTickets).BindDataGrid("Ticke t_Number");
}
}

<asp:Menu ID="mnuTicketMan" Width="100%" runat="server"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False"
OnMenuItemClick="mnuTicketMan_MenuItemClick">

<StaticMenuItemStyle CssClass=MenuCell ItemSpacing=0px />
<StaticHoverStyle CssClass=MenuCellHover />
<StaticSelectedStyle CssClass=MenuCellSelected ItemSpacing=0px />
</asp:Menu>

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

<%--New Ticket--%>
<asp:View ID="vwCreate_Ticket" runat="server">
<table width="100%" height="100%" cellpadding=0 cellspacing=0>
<tr>
<td class="Canvas">
<rgp:createTicket ID="rgpCreateTicket" runat="server" />
</td>
</tr>
</table>
</asp:View>
<%--End New Ticket--%>

<%--My Tickets--%>
<asp:View ID="vwMy_Tickets" runat="server" >
<table width="100%" height="100%" cellpadding=0 cellspacing=0>
<tr>
<td class="Canvas">
<asp:PlaceHolder ID="plhShowTickets" runat="server" />
<%-- <rgp:showTickets ID="rgpShowTickets" runat="server"
/--%>
</td>
</tr>
</table>
</asp:View>
<%--End My Tickets--%>
</asp:MultiView>
-------------------------------
usercontrol
-------------------------------
<%@ Control Language="C#" ClassName="showTickets" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="MySql.Data.MySqlClient" %>

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

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

public void Page_Load(Object source, EventArgs e)
{
conMain = new MySqlConnection("db_connection_goes_here");

if (this.IsPostBack)
{
//BindDataGrid("Ticket_Number");
}
}

public void BindDataGrid(string strSortField)
{
strSortDirection = "DESC";

string sql = "sql stuff here";

conMain.Open();
MySqlDataAdapter ad = new MySqlDataAdapter(sql, conMain);
DataSet ds = new DataSet();

ad.Fill(ds);

grdTickets.DataSource = ds;
grdTickets.DataBind();
conMain.Close();
}

public void grdTickets_PageIndexChanged(Object source,
GridViewPageEventArgs e)
{
grdTickets.PageIndex = e.NewPageIndex;
BindDataGrid("Ticket_Number");
}

</script>

<asp:GridView ID="grdTickets" runat="server" AllowPaging="true"
OnPageIndexChanging="grdTickets_PageIndexChanged" PageSize="15" >
<AlternatingRowStyle BackColor="Silver" />
</asp:GridView>
-------------------------------

Aug 9 '06 #1
0 1630

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

Similar topics

0
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...
2
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...
1
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...
1
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...
6
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...
9
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...
11
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...
4
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...
2
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
Oralloy
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,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.