Response.Redirect not displaying the desired data from the database in a GridView control

I am doing a project on Online Flight Reservation System.When the Home Page of my site is displayed, the user will select his departure station,date of departure,cabin-type etc, depending upon the type of trip he is making, i.e., whether One-Way or RoundTrip.Now on selecting the One-Way trip, the controls for return date(txtDateTo) and return cabin-type should get disabled.And after clicking on the button for flight-schedule search, the user will get redirected to next page which will show the schedules of selected flights in a GridView Control, which is not happening.

Here is the code of Home Page and its controls :

public partial class frmHome1 : System.Web.UI.Page



protected void btnBook_Click(object sender, EventArgs e)


"from"] = ddlFrom.SelectedItem.Text;  //dropdownlist control for selecting departure station

Session["to"] = ddlTo.SelectedItem.Text;    //dropdownlist control for selecting destination station

Session["departdate"] = txtDepart.Text;  //textbox for selecting date of departure

Session["fromcabin"] = ddlCabinFrom.SelectedItem.Text;   //dropdownlist control for selecting cabin type



protected void rdbRoundTrip_CheckedChanged(object sender, EventArgs e)


if (rdbRoundTrip.Checked.Equals(true))


txtDateTo.Enabled =
true;  //textbox for selecting return date

txtDateTo.BackColor = System.Drawing.Color.WhiteSmoke;

ddlCabinTo.Enabled = true;  //dropdownlist control for selecting cabin type during return

Session["arrivedate"] = txtDateTo.Text;

Session["tocabin"] = ddlCabinTo.SelectedItem.Text;




"arrivedate"] = null;Session["tocabin"] = null;



protected void rdbOneWay_CheckedChanged(object sender, EventArgs e)


if (rdbOneWay.Checked.Equals(true))


txtDateTo.Enabled =
false;ddlCabinTo.Enabled = false;



Here is the code of Flight Schedules page :

public partial class frm : System.Web.UI.Page


protected void Page_Load(object sender, EventArgs e)


string query;

string from = Convert.ToString(Session["from"]);

string to = Convert.ToString(Session["to"]);

string departdate = Convert.ToString(Session["departdate"]);

if ((Session["arrivedate"] == null) & (Session["tocabin"] == null))


query =
"select FlightNo,Origin,Destination,DepartDate,DepartTime,ArrivalTime,Duration,TicketPrice,TotalSeats,AvailableSeats from FlightInformation where Origin = '" + from + "' and Destination = '" + to + "' and DepartDate = '" + departdate + "'";




string adata = Convert.ToString(Session["arrivedate"]);query = "select * from FlightInformation where Origin = '" + from + "' and Destination = '" + to + "' and DepartDate = '" + departdate + "' and Rorigin = '"+ to +"' and Rdestination = '" + from +"' and ReturnDate = '" + adata +"' ";


SqlConnection conn = new SqlConnection("server = (local);uid=sa;pwd=sa;database=flymyway;Integrated Security=True");


SqlDataAdapter da = new SqlDataAdapter(query, conn);

DataSet ds = new DataSet();

da.Fill(ds, "FlightInformation");

GridView1.DataSource = ds.Tables["FlightInformation"];




protected void btnBookTicket_Click(object sender, EventArgs e)





Can anyone tell me where I am doing mistakes and why is it not happening ? 


6/20/2008 3:37:23 AM 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 33
Get it on Google Play
Get it on Apple App Store

I am not sure   you are not getting the value of following variables

string from = Convert.ToString(Session["from"]); ::--what is the value of this

string to = Convert.ToString(Session["to"]); ::--what is the value of this

Check it and reply it back if you are having any error please paste it that will help me to find the issue.

Nihar ranjan Nayak
Microsoft certified Professional
6/20/2008 9:11:19 AM

Similar Artilces:

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

How to add the data present in the controls to a table control without any database involvement.
Hi All,i am four controls where i will write the text and once i click the add button those should get added to the table .i want 6 columns fixed in the table and rows as many as required.i tried doing that taking a table server control and able to load the table.but the problem is whenver i am adding a new row the old one is gfetting overwritten by this and at the end i am getting only one row.  System.Web.UI.WebControls.Table t1 = new System.Web.UI.WebControls.Table();  i have declared the below one global TableRow tr; TableCell tc1; TableCell tc2; TableCell tc...

Bind Data to an Image Control not in a Data Presentation Control
I've been searching for two days but I don't really know what to search for.I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName.  The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ...

Drop Down Controls Don't Appear but Control data does when using Response.Redirect
The problem seems to start when I installed WebMatrix, and the IIS on XP Pro. I am using Web Controls, and accessing a database. Using VB.NET. When I click a Button/Hyperlink that does a Response.Redirect to another page the page loads, but all control graphics, and data entry methods do not. Alternatively if the page has a drop down box of say years then all the years are displayed across the screen with no drop down control. If I just start the page from Web Matrix without the link the page looks fine and works great. It even updates the database before it links to the next page an...

Update other controls after a Postback has fired from another control - eg insert data
Hi This is a slight modification to the personalweb template which shipped with VS2005 I have a web form - linked to a master with two content placeholders left and right: #1 In the left i have a formview containing a textbox + button - and a datasrouce object with an insertmethod - this calls a method to insert the textbox data into table albums: #2 In the right  i have a gridview which has a datasource this has a selectmethod which calls a select method from table albums. Because i am using a maser template with two content placeholders i cannot use the same ObjectD...

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

Re-displaying a GridView control when Selecting different data from database
I am trying to do something that I suspect is very common and should be simple.  I have a DropDownList control and a Gridview control on a page, each with an SqlDataSource as the data source.  The operation I'm desiring is that when a user picks a different item in the DropDownList, a new Select query is performed on the GridView data source and the new data is shown in the GridView.  I have attached my code-behind code.  The behavior is that the GridView is initially populated appropriately but when I change the selection on the DropDownList, nothing happens.  A...

ajax control in data presentation controls
can i add ajax controls (MaskedEdit) to presentation controls (dataGrid, dataForm)?? Hi,of course. But keep in mind that those controls are extenders, so you append them to an existing control. Just convert your GridView / DetailsView-fields into templated fields and add the extender you'd like to use to the controls.RegardsMarco Buerckel Don't forget to mark posts that were helpful as answers. Actually, if you looked at the source code for the Masked Edit Extender, you'd see  [TargetControlType(typeof(TextBox))]Meaning, targeting any control type other than textboxes...

data presentation controls (how to call the individual controls)
Hi please help me.,i have this question., example i create a site with one control, like textbox. when i double click on the white page, the page load event, in the intellisense, the textbox is visible, but when a formview with a textbox inside, in the same page load event, intellisense, the textbox is not available. how can i do the simple intellisense calling where the textbox is just outside a data presentation control like formview. i mean by this intellisense calling is in VB code view., thanks JFRBPH12™  The textbox is within the formview then you can find it like this...

Menu control is displaying behind Gridview control
I have placed a menu control just above the gridview control but when i click the menu control it displaysome of the menu options and rest of the menu options display behind the gridview.Is there anyway any option which make the menu to display over gridview.Mark as answer if anybody's post has helped you Typically the ZIndex will control that: Kiff "Mark As Answer" If my reply helped you --...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

-- Need to Display data in two GridView controls, but second one could not be displayed?
Dear all, I wrote a code segment to display data in two GridView controls one by one as below. The first one is displayed ok. But, the second one is not displayed. Did I miss anything?         ads.DataFile = "~/App_Data/color_match_live.mdb"                ads.SelectCommand = "SELECT COUNT(*) FROM [tech_mstr] WHERE [month] = ?"        ads.SelectParameters.Add("month", sel_month)        Di...

Controls to display Data from database
Hi. I am looking into displaying a product with product details in the format of a picture with the data underneath going down vertically.  I want to display the products 3 acrross by 4 down (12 per page) and was wondering what control would be the best one to use to get the desired result?  Which control would provide more formatting functionality? Thanks Repeater Hi, Try this   Thanks,Mark as answer if this post helpfull to you.Don't be afraid to be wrong; otherwise you'll never be right....

Gridview control not displaying my data
My gridview control appears set correctly.  Nothing displays at run time. I am using a sqldatasource (sqlserver).  At design time, with the wizard, the sql statments are executed  via the TEST Query Button then data is always returned.  No error messages are displayed.  No Gridview either. Imports System.DataPartial Class _DefaultInherits System.Web.UI.Page     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         GridView3.DataBind()     End Su...

Web resources about - Response.Redirect not displaying the desired data from the database in a GridView control -

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 11/29/2015 6:46:17 AM