I am trying to implement a DataView for a DataGrid so I can sort at runtime
by clicking on column headers. My initial page load works... it displays
the data However, when I click a column heading at run time, the data
doesn't sort as expected, in fact, the DataGrid becomes empty, all I see are
column headings:
SqlConnection sqlConnection;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected ProjContMan.dsProjByDate dsProjByDate;
protected System.Data.DataView dataView;
SqlDataAdapter sqlDataAdapter;
private void Page_Load(object sender, System.EventArgs e)
{
sqlConnection = (SqlConnection)Session["sqlConnection"];
sqlDataAdapter = (SqlDataAdapter)Session["sqlDataAdapter"];
if(!IsPostBack)
{
sqlDataAdapter.Fill(dsProjByDate);
DataGrid1.DataSource=dataView;
DataGrid1.DataBind();
}
}
private void DataGrid1_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
dataView.Sort=e.SortExpression;
DataGrid1.DataBind();
}
--
Thanks,
Martin Schmid, EIT, CCSA, MCDBA, MCSE 4 1471
Martin,
Do you have the viewstate enabled on the page? If you do not, then the
data on the grid will not be post back to the page for repopulation (you are
filling the grid only when it is not a postback, so that is why the grid is
empty).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I am trying to implement a DataView for a DataGrid so I can sort at
runtime by clicking on column headers. My initial page load works... it displays the data However, when I click a column heading at run time, the data doesn't sort as expected, in fact, the DataGrid becomes empty, all I see
are column headings:
SqlConnection sqlConnection; protected System.Web.UI.WebControls.DataGrid DataGrid1; protected ProjContMan.dsProjByDate dsProjByDate; protected System.Data.DataView dataView; SqlDataAdapter sqlDataAdapter;
private void Page_Load(object sender, System.EventArgs e) { sqlConnection = (SqlConnection)Session["sqlConnection"]; sqlDataAdapter = (SqlDataAdapter)Session["sqlDataAdapter"]; if(!IsPostBack) { sqlDataAdapter.Fill(dsProjByDate); DataGrid1.DataSource=dataView; DataGrid1.DataBind(); } }
private void DataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEvent Args e) { dataView.Sort=e.SortExpression; DataGrid1.DataBind(); }
-- Thanks, Martin Schmid, EIT, CCSA, MCDBA, MCSE
EnableViewState for DataGrid1 is true, as is enableViewState for DOCUMENT.
--
Thanks,
Martin Schmid, EIT, CCSA, MCDBA, MCSE
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O6**************@TK2MSFTNGP11.phx.gbl... Martin,
Do you have the viewstate enabled on the page? If you do not, then
the data on the grid will not be post back to the page for repopulation (you
are filling the grid only when it is not a postback, so that is why the grid
is empty).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I am trying to implement a DataView for a DataGrid so I can sort at runtime by clicking on column headers. My initial page load works... it
displays the data However, when I click a column heading at run time, the data doesn't sort as expected, in fact, the DataGrid becomes empty, all I see are column headings:
SqlConnection sqlConnection; protected System.Web.UI.WebControls.DataGrid DataGrid1; protected ProjContMan.dsProjByDate dsProjByDate; protected System.Data.DataView dataView; SqlDataAdapter sqlDataAdapter;
private void Page_Load(object sender, System.EventArgs e) { sqlConnection = (SqlConnection)Session["sqlConnection"]; sqlDataAdapter = (SqlDataAdapter)Session["sqlDataAdapter"]; if(!IsPostBack) { sqlDataAdapter.Fill(dsProjByDate); DataGrid1.DataSource=dataView; DataGrid1.DataBind(); } }
private void DataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEvent Args e) { dataView.Sort=e.SortExpression; DataGrid1.DataBind(); }
-- Thanks, Martin Schmid, EIT, CCSA, MCDBA, MCSE
Martin,
When you look at the page that is sent to the browser, do you see the
viewstate persisted to the page in a hidden form field?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message
news:ea**************@TK2MSFTNGP10.phx.gbl... EnableViewState for DataGrid1 is true, as is enableViewState for DOCUMENT.
-- Thanks, Martin Schmid, EIT, CCSA, MCDBA, MCSE "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:O6**************@TK2MSFTNGP11.phx.gbl... Martin,
Do you have the viewstate enabled on the page? If you do not, then the data on the grid will not be post back to the page for repopulation (you are filling the grid only when it is not a postback, so that is why the grid is empty).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I am trying to implement a DataView for a DataGrid so I can sort at runtime by clicking on column headers. My initial page load works... it displays the data However, when I click a column heading at run time, the data doesn't sort as expected, in fact, the DataGrid becomes empty, all I
see are column headings:
SqlConnection sqlConnection; protected System.Web.UI.WebControls.DataGrid DataGrid1; protected ProjContMan.dsProjByDate dsProjByDate; protected System.Data.DataView dataView; SqlDataAdapter sqlDataAdapter;
private void Page_Load(object sender, System.EventArgs e) { sqlConnection = (SqlConnection)Session["sqlConnection"]; sqlDataAdapter = (SqlDataAdapter)Session["sqlDataAdapter"]; if(!IsPostBack) { sqlDataAdapter.Fill(dsProjByDate); DataGrid1.DataSource=dataView; DataGrid1.DataBind(); } }
private void DataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEvent Args e) { dataView.Sort=e.SortExpression; DataGrid1.DataBind(); }
-- Thanks, Martin Schmid, EIT, CCSA, MCDBA, MCSE
I have revised my code as follows... but I don't understand what is going on
yet. Do I have any redundancies ... any explanation is helpful!
SqlConnection sqlConnection;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected ProjContMan.dsProjByDate dsProjByDate;
protected System.Data.DataView dataView;
SqlDataAdapter sqlDataAdapter;
private void Page_Load(object sender, System.EventArgs e)
{
sqlConnection = (SqlConnection)Session["sqlConnection"];
sqlDataAdapter = (SqlDataAdapter)Session["sqlDataAdapter"];
if(!IsPostBack)
{
DataGrid1.DataSource=dataView;
}
sqlDataAdapter.Fill(dataView.Table);
DataGrid1.DataBind();
}
private void DataGrid1_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
dataView.Sort=e.SortExpression;
DataGrid1.DataBind();
}
--
Thanks,
Martin Schmid, EIT, CCSA, MCDBA, MCSE
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uY**************@TK2MSFTNGP12.phx.gbl... Martin,
When you look at the page that is sent to the browser, do you see the viewstate persisted to the page in a hidden form field?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message news:ea**************@TK2MSFTNGP10.phx.gbl... EnableViewState for DataGrid1 is true, as is enableViewState for
DOCUMENT. -- Thanks, Martin Schmid, EIT, CCSA, MCDBA, MCSE "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:O6**************@TK2MSFTNGP11.phx.gbl... Martin,
Do you have the viewstate enabled on the page? If you do not,
then the data on the grid will not be post back to the page for repopulation
(you are filling the grid only when it is not a postback, so that is why the
grid is empty).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... > I am trying to implement a DataView for a DataGrid so I can sort at runtime > by clicking on column headers. My initial page load works... it displays > the data However, when I click a column heading at run time, the
data > doesn't sort as expected, in fact, the DataGrid becomes empty, all I see are > column headings: > > SqlConnection sqlConnection; > protected System.Web.UI.WebControls.DataGrid DataGrid1; > protected ProjContMan.dsProjByDate dsProjByDate; > protected System.Data.DataView dataView; > SqlDataAdapter sqlDataAdapter; > > > private void Page_Load(object sender, System.EventArgs e) > { > sqlConnection = (SqlConnection)Session["sqlConnection"]; > sqlDataAdapter = (SqlDataAdapter)Session["sqlDataAdapter"]; > if(!IsPostBack) > { > sqlDataAdapter.Fill(dsProjByDate); > DataGrid1.DataSource=dataView; > DataGrid1.DataBind(); > } > } > > > private void DataGrid1_SortCommand(object source, > System.Web.UI.WebControls.DataGridSortCommandEvent Args e) > { > dataView.Sort=e.SortExpression; > DataGrid1.DataBind(); > } > > > > > -- > Thanks, > Martin Schmid, EIT, CCSA, MCDBA, MCSE > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Maciej Nadolski |
last post by:
Hi!
I`ve got a simple question but I`m puzzled:( When I create variable: for example
$query for query to MySQL its obvieus that I want to use...
|
by: gene.ellis |
last post by:
Good morning. I am racking my brains over what seems like should be a
simple question. I have a string that contains text and html.
Basically, I...
|
by: Kirk |
last post by:
A very simple question for anyone who knows their HTML tags and
attributes.
Is there an atribute that I can use to hide the white space around a...
|
by: calfliu |
last post by:
hello:
everybody! I have a simple question. How can I translate the selected
value
from art to recipient(hidden input button)?
<form...
|
by: Anurag |
last post by:
This simple one beats me all ends up(sincerely).
I have been doing DB2 UDB for some time now, reading a lot of good
discussions in this forum,...
|
by: Peter |
last post by:
Hello
Thanks for reviewing my question. I would like to know how can I programmatically select a node
Thanks in Advanc
Peter
|
by: Brad |
last post by:
I have another hopefully simple question. I am so used to writing VB .Net
windows apps that there are some things in ASP .Net that just does not...
|
by: abcd |
last post by:
I am trying to set up client machine and investigatging which .net
components are missing to run aspx page.
I have a simple aspx page which just...
|
by: Allain Bøge |
last post by:
It is really a simple question.
Visual Basic .NET (2003)
I create 2 forms (Form1 and Form2)
I create a checkbox in Form1 (checkbox1)
I...
|
by: AlBen |
last post by:
Hello
sorry I don't know about javascript but I have to finish my work and
there I have some scripts
on my page I have a textarea form and a ...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
| |