473,322 Members | 1,504 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,322 software developers and data experts.

Simple(?) DataView Question

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
Nov 15 '05 #1
4 1516
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

Nov 15 '05 #2
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


Nov 15 '05 #3
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



Nov 15 '05 #4
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
>
>



Nov 15 '05 #5

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

Similar topics

5
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 variables. Now should I do something like that: 1)...
7
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 would like to grab the HTML tags from the string and...
2
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 table which I have used to fill an entire page? ...
6
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 name="send" method="post" action="send.cgi"> <select...
2
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, writing some answers, asking a lot more but this...
3
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
3
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 easily cross over. I know how to pass variables to...
7
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 has "hello world" printed.... When I request...
2
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 create a checkbox in Form2 (checkbox1) I go to Form1...
17
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 select form when a user click in the select form...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.