Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   SqlDataSource, GridView (http://www.velocityreviews.com/forums/t763165-sqldatasource-gridview.html)

zp 03-11-2007 11:18 AM

SqlDataSource, GridView
 
Hi there,
Have a web page with SqlDataSource and GridView (.NET 2) that gets and
displays data from database. The connection to the database is opened on page
load and the grid is populated. I have no problem at all on my testing
machine, IIS5 or VS development server, but when I deploy it on a remote
server (win2003, IIS6) and the page is displayed the data not showing in the
grid all the time. Some times I have to click several times back and forth in
order the grid to be populated with data. This is the code I use on page load
event:

protected void Page_Load(object sender, EventArgs e)
{
try
{
string LClassTutor;
LClassTutor = (String)Session["UserId"];
Parameter Parameter1 = new Parameter();
Parameter1.Name = "@CR";
Parameter1.Type = TypeCode.String;
Parameter1.DefaultValue = LClassTutor;
DsStdOnClass.SelectParameters.Add(Parameter1);
GvStudents.DataBind();

}
catch
{
Session["ERROR"] = "Parameters definition";
Server.Transfer("Error.aspx", true);
}
}

Have tried many variation of the above code but the problem persists. Any
suggestion where to look for possible solution?

Thanks
zp


zp 03-12-2007 05:49 AM

RE: SqlDataSource, GridView
 
Answering my own question. The problem was in the lost session value. I've
used a session to store the user login info, which was used as a parameter
(@CR) in the query. The IIS6 kills the session for some reasons, and the
value is reset, so my user id was lost, and the query failed. I've decided to
use Cookies to store the value of the user id and all is working fine now.
--
zp


"zp" wrote:

> Hi there,
> Have a web page with SqlDataSource and GridView (.NET 2) that gets and
> displays data from database. The connection to the database is opened on page
> load and the grid is populated. I have no problem at all on my testing
> machine, IIS5 or VS development server, but when I deploy it on a remote
> server (win2003, IIS6) and the page is displayed the data not showing in the
> grid all the time. Some times I have to click several times back and forth in
> order the grid to be populated with data. This is the code I use on page load
> event:
>
> protected void Page_Load(object sender, EventArgs e)
> {
> try
> {
> string LClassTutor;
> LClassTutor = (String)Session["UserId"];
> Parameter Parameter1 = new Parameter();
> Parameter1.Name = "@CR";
> Parameter1.Type = TypeCode.String;
> Parameter1.DefaultValue = LClassTutor;
> DsStdOnClass.SelectParameters.Add(Parameter1);
> GvStudents.DataBind();
>
> }
> catch
> {
> Session["ERROR"] = "Parameters definition";
> Server.Transfer("Error.aspx", true);
> }
> }
>
> Have tried many variation of the above code but the problem persists. Any
> suggestion where to look for possible solution?
>
> Thanks
> zp
>



All times are GMT. The time now is 04:24 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.