Forms Data Controls :: GridView Disappears After Postback?
Jan 13, 2010
I have a gridview where in the users are allowed to edit certain data and there is an update on top of the page which will send out all the changes made inside the GridView. But, the problem is , as soon as the update button is clicked, the grid disappearsand no update is made. This problem occurs when the size of the data on the page is huge. When we have less amount of data on the gridview, It does update. But, when there is a huge amount of data on the gridview, it does not. We have tried to increase the page size on the server, but to no use.
View 3 Replies
Similar Messages:
Feb 23, 2010
I've got a Gridview in which I use the RowDataBound handler to color the lines according to certain conditions
(ie if column x is value y then change the background-color of the row to z etc).
One problem though, as soon as I do a postback the coloring disappears altogether and all rows become white.
Is there some way around this so I can retain my background colors even after a postback?
View 14 Replies
Jun 1, 2010
I have a datarepeater inside which I load a gridview. After the grid's binding is done I create an extra header line to group the columns (that's the only way I could do it, I couldn't figure a way to add an event for a control inside the repeater).That works fine and the page displays perfectly.However everytime I do a postback from other controls, I lose the 2nd header and 1 extra empty line appears at the top of the gridview
View 5 Replies
May 4, 2010
have an ASP.net 4.0 page containing a GridView, where during the Page_Init event I'm dynamically adding BoundField columns to the gridview. I also have some custom sorting and paging methods that I use with this gridview, which result in postbacks on the page. In Chrome, Firefox, Safari, and Opera the gridview behaves as expected. HOWEVER, in IE 6, 7, or 8 when I click to sort a column in the gridview, or go to the next page of results in the gridview, it does not bind on postback, returning nothing back to the browser. Again, in anything but Internet Explorer, paging and sorting (frankly any postback event) brings back the gridview in its expected state. I only have the problem in IE. Relevant snippets of my code follow, where you'll see my Page_Init event calling a method in my WebFunctions class to add the BoundField columns for the table I pass to it, and my Page_Load event that calls the method in the user control responsible for binding my dataset to the gridview. Initial page load works in all browsers, but postback loading of the gridview only works in non-IE browsers.
[Code]....
View 4 Replies
Oct 1, 2013
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[code]....
my data in gridview4 disappears when i click add to cart it shows no data again i have to pass a query from gridview 3 and then gridview 4 appears and then again if i click on add to cart in gridview 4 it shows no data.
View 1 Replies
Jul 24, 2010
I'm trying to figure out why my gridview disappears when I trigger the rowediting event.
The Gridview:
[Code]....
The code-behind:
[Code]....
When I click on the edit linkbutton, the gridview disappears. What is going wrong?
View 13 Replies
Jan 18, 2011
I use Server.Transfer("pagename", True) to navigate from a page where two dates have been selected to a page with a gridview that uses the dates to query the database and display the results. The gridview initially displays correctly but when I operate the select or sort it disappears.
View 8 Replies
Jan 21, 2011
I am populating a column in a gridview with a dropdownlist as follows:
[Code]....
[Code]....
When I edit the gridrow, the dropdown is there and I can select a new item.
But I can't find the dropdown during the rowupdated event. The cell control says it's a Textbox. All of the other items in the row are fine and I can get the data back. But I can't get the DropDown item.
Here are some of the things I have tried in the RowUpdating event:
DropDownList test = (DropDownList)e.FindControl("ddlPeriod");
//null
DropDownList ddl = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlPeriod");
//Also null
var test = row.Cells[8].Controls[0];
//Says its a textbox.
View 5 Replies
Apr 1, 2011
I have a gridview with daatsource from MembershipUserCollection. When my collection doesn't contain any records the gridview just disappears. I want to display the empty gridview indicating no records exist rather than the grid just become invisible.
How to make gridview always visible ?
View 4 Replies
Jul 28, 2010
I have a page with a TextBox, a Button, a GridView, and a SqlDataSource. I click the Button to execute the SQL in the TextBox using the SqlDataSource. The SqlDataSource populates the GridView. Everything works as expected until I click a column heading to sort.
When I click a column heading, the GridView disappears and I have to click the Button to display the grid again. When I do, the grid is displayed in the order of the column I clicked.
I don't understand why the GridView is disappearing when I click a column header.
Does anyone know how to fix this so the GridView is sorted and displayed only by clicking the column header?
ASPX:
[Code]....
Code behind:
[Code]....
View 9 Replies
Jun 15, 2010
I have a small problem I am returning some data from a query and have allowed paging, however when I click on the next button to view the following page the gridview disappears.
My datasource is specified in the code behind:
<asp:Panel ID="dtpanel" runat="server" Visible="False">
<asp:GridView ID="grddetails" runat="server" AutoGenerateColumns="False" AllowPaging="True"
OnPageIndexChanging="grddetails_SelectedIndexChanged" ViewStateMode="Enabled"
onselectedindexchanged="grddetails_SelectedIndexChanged" AllowSorting="True" >
<Columns>
<asp:BoundField DataField="Col1" HeaderText="Col1" SortExpression="Col1" />
<asp:BoundField DataField="Col2" HeaderText="Col2" SortExpression="Col2" />
<asp:BoundField DataField="Col3" HeaderText="Col3" SortExpression="Col3" />
<asp:BoundField DataField="Col4" HeaderText="Col4" SortExpression="Col4" />
<asp:BoundField DataField="Col5" HeaderText="Col5" SortExpression="Col5" />
<asp:BoundField DataField="Col6" HeaderText="Col6" SortExpression="Col6" />
</Columns>
</asp:GridView>
</asp:Panel>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView2_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
int y = Convert.ToInt32(e.CommandArgument);
Control control = GridView2.Rows[y].Cells[0].Controls[0];
LinkButton btn = control as LinkButton;
string qval = btn.Text;
string query = "SELECT * FROM Table WHERE Col LIKE '%" + qval + "%'";
string connectionString = @"Data Source=servername;Initial Catalog=dbname;Integrated Security=True";
SqlConnection accessConnection = new SqlConnection(connectionString);
SqlCommand accessCommand = new SqlCommand(query, accessConnection);
SqlDataAdapter grddetailsDataAdapter = new SqlDataAdapter(accessCommand);
DataTable grddetailsDataTable = new DataTable("Table");
grddetailsDataAdapter.Fill(grddetailsDataTable);
int dataTableRowCount = grddetailsDataTable.Rows.Count;
if (dataTableRowCount > 0)
{
grddetails.DataSource = grddetailsDataTable;
grddetails.DataBind();
}
dtpanel.Visible = true;
}
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
int w = Convert.ToInt32(e.CommandArgument);
Control control = GridView1.Rows[w].Cells[0].Controls[0];
LinkButton btn = control as LinkButton;
string qval2 = btn.Text;
Label1.Text = btn.Text; string query = "SELECT * FROM Table WHERE Col LIKE '%" + qval2 + "%'";
string connectionString = @"Data Source=servername;Initial Catalog=dbname;Integrated Security=True";
SqlConnection accessConnection = new SqlConnection(connectionString);
SqlCommand accessCommand = new SqlCommand(query, accessConnection);
SqlDataAdapter grddetailsDataAdapter = new SqlDataAdapter(accessCommand);
DataTable grddetailsDataTable = new DataTable("Table");
grddetailsDataAdapter.Fill(grddetailsDataTable);
grddetails.DataSource = grddetailsDataTable;
grddetails.DataBind();
dtpanel.Visible = true;
}
protected void grddetails_SelectedIndexChanged(object sender, GridViewPageEventArgs e)
{
DataTable dataTable = grddetails.DataSource as DataTable;
grddetails.PageIndex = e.NewPageIndex;
grddetails.DataBind();
dtpanel.Visible = true;
}
}
View 5 Replies
Mar 16, 2010
I have a gridview with Edit buttons, which turn into Update buttons when pressed:
[Code]....
It worked fine before I added DBInterfaceGridView_RowEditing handler:
[Code]....
Now it seems to be working in Debug mode, but in Release when I press Edit, the gridview just disappears.
View 3 Replies
Jan 7, 2011
I am creating a custom control to show message to the user. The custom control is having 2 labels and one button.
I dragged the control in aspx page .
<cc1:MessageBox ID="MessageBox1" runat="server" />
Then i am calling a methos called show to show message to the user.
MessageBox1.Show("applicationname", "Message");
View 3 Replies
Jan 19, 2010
I've coded myself into a state of confusion. I have a form with a postal code TextBox and a country DropDownList both inside an UpdatePanel. When the selected country is changed, the DropDownList auto posts back and sets the regular expression used for validating the postal code. The country DropDownList also has a RequiredFieldValidator. The first item in my DropDownList is empty (Value = Text = String.Empty) and when I select this item, I momentarily see the RequiredFieldValidator appear and then disappear. It seems that the client side script is displaying the error message, but then after my partial postback it disappears. I can see in the country DropDownList's SelectedIndexChanged event handler that the RequiredFieldValidator has IsValid = false, so why doesn't the error message stay visible?
View 7 Replies
Jan 30, 2010
I have an asp.net textbox like this:
<asp:TextBox ID="PINPad" runat="server" Columns="6" MaxLength="4"
CssClass="PINTextClass"></asp:TextBox>
It is, as you might have guessed, the text box from an on screen PIN pad. Javascript fills in the values. The page is posted back every five seconds (using an update panel if that matters) to update various other unrelated items on the screen. This works just fine. However, when I convert it to a password text box, like this:
<asp:TextBox ID="PINPad" runat="server" Columns="6" MaxLength="4"
CssClass="PINTextClass" TextMode="Password"></asp:TextBox>
Then whenever the page posts back, the text box is cleared out on the screen and the textbox is empty (though during the timer event, the value does make it back to the server.)
View 1 Replies
Feb 21, 2011
I have an asp:UpdatePanel in my .aspx page.Within the panel I have placed an infragistics ultrawebgrid control.Upon clicking a button (placed outside the panel) , I have to export the data in the grid to excel.I am using
UltraWebGridExcelExporter(Infragistics object) for this. The export will occur only with full postback.For this I have added a PostBack tigger for the button to the update panel.But once the export is complete, if I change the selected item in a dropdownlist(Autopostback="true") in the same page,the updatepanel gets invisible.
View 1 Replies
Apr 4, 2011
I have a link button:
<asp:LinkButton ID="LinkButtonPrint" runat="server" OnClick="OnPrint_Click">
<img src="img/print-icon.png" alt="" />
<asp:Literal runat="server" Text="<%$ Resources:PrintPage %>" />
</asp:LinkButton>
In code behind I add an onclick handler in Page_Load like this:
LinkButtonPrint.Attributes["onclick"] = "StartLoadTracking(this, '" + GetLocalResourceObject("Loading") + "')";
The rendered HTML is like this:
<a href="javascript:__doPostBack('ctl00$LinkButtonPrint','')"
id="ctl00_LinkButtonPrint" onclick="StartLoadTracking(this, 'Loading...');">
<img alt="" src="img/print-icon.png">Print page
</a>
If I click this button it is working OK (it will respond with a PFD file so no HTML is sent back to the browser), but if I click another button on the page (which makes a full postback) the LinkButtonPrint will not have the inner content, it will be rendered like this:
<a href="javascript:__doPostBack('ctl00$LinkButtonPrint','')"
id="ctl00_LinkButtonPrint" onclick="StartLoadTracking(this, 'Loading...');"></a>
If I remove the LinkButtonPrint.Attributes["onclick"] = ... line from Page_Load everything works fine (except my js function is not called, but that is normal).
What am I missing here?
EDIT
This is duplicate of asp.net Link button image not visible after postback.
View 2 Replies
Jan 10, 2011
I'm trying to extend the GridView control to enable sorting and paging for any situation.
When using my control I am fetching data from a database and filling a DataSet with it, then binding the GridView upon every page load. My first question would be, is this the correct approach?
To sort the GridView I am overriding the OnSorting method which stores the sort expression and direction in the ViewState, then creates a DataView and utalises the Sort method to sort the underlying data. It then sets the Data Source to this DataView and rebinds the GridView.
Paging is handled by OnPageIndexChanging which simply sets the PageIndex property and again rebinds the GridView.
My problem is; when any control causes a postback my GridView is no longer sorted, presumably because it is persistently rebound. If I don't rebind it then the GridView is empty on postback since the data isn't automatically stored in the ViewState. I have considered saving the data source in the ViewState but I would assume that this is bad practice for large amounts of data? - also DataViews are not seralisable.
The only solution I can think of currently is to override OnDataBound and sort the data every time. This results in a double sort when paging triggers a postback which seems inefficient. Code illustration of this below,
[Code]....
I'm looking for the cleanest 'best practice' solution as this is a learning exercise more than anything else.
View 12 Replies
Mar 24, 2010
I have a linkbutton inside a updatepanel and when the update panel does a partial page rendering, the linkbutton disappears.
<asp:UpdatePanel ID="up" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="drp" runat="server" AutoPostBack="true" CausesValidation="true">
<asp:ListItem Text="" Value="" />
<asp:ListItem Text="a" Value="a" />
<asp:ListItem Text="b" Value="b" />
<asp:ListItem Text="c" Value="c" />
</asp:DropDownList>
<asp:LinkButton ID="link" Text="abc" runat="server" />
</ContentTemplate>
I think that is because the link button is rendered using a script and that script is not run after the post back.
View 1 Replies
Aug 9, 2010
I am running Visual Studio 2008 Version 9.0.30720.1. I created a Web App with a FromView and in IE7 it works great. My company pushed an upgrade to IE8 and all of a sudden when I run my Web App to test it, the formview completely dissapears. I tried running IE8 in Compalability View but it still does not work.
View 5 Replies
Jul 12, 2010
when i add a rowdatabound event to a gridview, the pager disappears. when i remove
onrowdatabound="gridview1_rowdatabound"
from gridview, pager comes back to life.
View 3 Replies
May 7, 2015
My combobox and asp:fileupload and imagepreview all are inside update panel , my combobox is doing postback after which my image disappears.... how to retain back image after postback ?
In [URL] .... if I remove input:file and put asp:file then it will be possible ... here's all code:
using System;
using System.Drawing;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default3 : Page
[Code] ....
View 1 Replies
Feb 11, 2010
I have a gridview that I only want to show if the page is a postback. I'm not a very good programmer. show me some VB code that will assist this. I think I want to use a page load event and IF NOT Postback then visible = false for my gridview but I don't know how to write it out...
View 4 Replies
Nov 3, 2010
i have a global field called hotelId. i then have this piece of code that gets a value from gridview row:
[Code]....
the local variable is assigned to my global one, which gets passed to my method along with other variables. while stepping through i can see the value is set, but when i hit the submit button variabl is passed to another method except my hoteId. it gets lost...
View 3 Replies
Feb 9, 2011
I design a page which contains one dropdownlist, gridview1 and gridview2. All of them extract data from the same table (a SqlDataSource). The Gridview1 is used to edit, update data with edit, update and cancel button. My problems are:
1. After update gridview1, the dropdownlist and gridview2 don't update data.
2.After updata gridview1, the gridview1 resets to its original state if refresh page.
View 4 Replies