Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with DataGrid

Status
Not open for further replies.

PIAS

Programmer
Nov 2, 2005
38
0
0
SI
In my web application i have one page that uses DataGrid component. This DataGrid is connected with database trough a dataSource with common select statemant ( select * from table). I set properties of DG AllowPaging on True and AllowSorting on True.

When i compile program and open this page it shows me data in mentioned DataGrid, paging and sorting doesn't work. It shows paging control and collumn name as link, but when i click on it just refreshes the grid but it doesn't changes the content of the grid.

Can anyone tell me what can be wrong?

Thanks!

PIAS
 
Where are you binding the datasource to the datatable? Are you doing it on page load without adding

Code:
if (!IsPostBack)
{
}

?

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
If you are doing it upon page load without it being in the !IsPostBack if statement, the datagrid will re-bind on every post back to its original state.

To do paging, the original binding needs to only happen upon the very first time the page loads.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
But i do use


if (!IsPostBack)
{

}

so why is not working?
 
I asked if you were doing it without !IsPostBack and you said yes, hence my confusion.

Can you post your code so that we can examine what might be wrong?

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Sory, my bad...

here is the code:

protected void Page_Load(object sender, EventArgs e)
{
//Put user code to initialize the page here
funkcije.preverisession();
if (!Page.IsPostBack)
{
ViewState["sort"] = 0;
ViewState["sortField"] = "a.Adv_name";
bindDataGrid();
if (Cache["tabelaTip"] == null)
{
bindAdvType();
}
advType.DataTextField = "Type_name";
advType.DataValueField = "Type_id";
advType.DataSource = Cache["tabelaTip"];
advType.DataBind();
lnkDelMedia.Attributes.Add("onClick", "vbscript:preveriMedije '" + lstMediji.ClientID + "'");
lnkDelProduct.Attributes.Add("onClick", "vbscript:preveriIzdelke '" + lstProducts.ClientID + "'");
}
else
{
Int16 vrsta;
vrsta = Convert.ToInt16(Request.Form["vrsta"]);
if (vrsta == 1)
{
fillMedije();
}
else if (vrsta == 2)
{
fillProducts();
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top