0

On this project. I used XML as a database and AJAX for display.. I integrated this website
Here's the full source code.. please scan it for your safety.
http://www.mediafire.com/?nh14oi1mmeo

First, radiobuttons is assigned before page init..

public partial class Default : System.Web.UI.Page
{
//Assign values as a specific Dynamic WebControl Creation.
List<RadioButton> radioButtons = new List<RadioButton>();
List<CheckBox> checkBoxes = new List<CheckBox>();

Then I created a class that would dynamically create a table containing the available flights depending on session.. (See CallPageLoad())

The placeholder and button is inside the UpdatePanel...

on the button inside the update panel, (btnSelect)

i have this code which works...

protected void btnSelect_Click(object sender, EventArgs e)
{

Label1.Text = Convert.ToString(radioButtons.Count);

It detects the number of radiobuttons that were dynamically created...

But when I use the following code inside the BtnSelectClick event...

foreach (RadioButton button in radioButtons)
{
if (button.Checked == true)
{
Label1.Text = "You select... " + button;

CallPageLoad();
}

}

It does not work even though the dynamically created radiobuttons were already clicked..

Before I integrated to AJAX, this code was working...

Here's the Web Form...

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>CAFEKUN AIR</title>
 <!-- Includes-->
<script type="text/javascript" src="JQuery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="JQuery/datepicker/jquery.datepick.js"></script>
<style type="text/css">@import "JQuery/datepicker/jquery.datepick.css";</style>
<script type="text/javascript" src="JQuery/thickbox.js"></script>
<link rel="stylesheet" href="JQuery/thickbox.css" type="text/css" media="screen" />
<script type="text/javascript"> 
$(document).ready(function() {	
 
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});
 
</script> 
<style> 
body {
font-family:verdana;
font-size:15px;
}
 
a {color:#333; text-decoration:none}
a:hover {color:#ccc; text-decoration:none}
 
#mask {
  position:absolute;
  left:0;
  top:0;
  z-index:9000;
  background-color:#000;
  display:none;
}
  
#boxes .window {
  position:absolute;
  left:0;
  top:0;
  width:440px;
  height:200px;
  display:none;
  z-index:9999;
  padding:20px;
}
 
#boxes #rules {
  width:1000px; 
  height:603px;
  padding:10px;
  background-color:#ffffff;
}
 
#boxes #dialog1 {
  width:375px; 
  height:203px;
}
 
#dialog1 .d-header {
  background:url(images/login-header.png) no-repeat 0 0 transparent; 
  width:375px; 
  height:150px;
}
 
#dialog1 .d-header input {
  position:relative;
  top:60px;
  left:100px;
  border:3px solid #cccccc;
  height:22px;
  width:200px;
  font-size:15px;
  padding:5px;
  margin-top:4px;
}
 
#dialog1 .d-blank {
  float:left;
  background:url(images/login-blank.png) no-repeat 0 0 transparent; 
  width:267px; 
  height:53px;
}
 
#dialog1 .d-login {
  float:left;
  width:108px; 
  height:53px;
}
 
#boxes #dialog2 {
  background:url(images/notice.png) no-repeat 0 0 transparent; 
  width:326px; 
  height:229px;
  padding:50px 0 20px 25px;
}
</style> 

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="0px" cellpadding="0px" cellspacing="0px" style=" width: 100%;">
            <tr>
                <td colspan="4" style="height: 19px">
                </td>
            </tr>
            <tr>
                <td colspan="4" style="height: 506px; text-align: center;" valign="top">
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <br />
                    <table style="width: 889px;">
                        <tr>
                            <td colspan="5" style="height: 30px; text-align: left">
                                <span style="font-size: 14pt; color: #696969; font-family: Arial">Select Flight</span></td>
                        </tr>
                        <tr>
                            <td colspan="5" style="text-align: left">
                                <span style="font-size: 10pt; color: dimgray; font-family: Arial"><span style="font-size: 9pt;
                                    color: mediumblue">Sorry, either the fares have been sold out or there are no flights
                                    available on your chosen date/s. The closest available date have been shown instead.<br />
                                </span><strong><span style="color: red"></span></strong> </span></td>
                        </tr>
                        <tr>
                            <td colspan="5" valign="middle" style="height: 164px">
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <span style="font-size: 10pt"><span style="font-family: Arial"><strong><span style="color: #ff0000">
                                            <asp:ImageButton ID="imgPreviousDayDepart" runat="server" ImageUrl="~/Images/PREVDAY.PNG" OnClick="imgPreviousDayDepart_Click" />FLIGHT
                                            OPTIONS</span></strong><span style="color: #696969"> </span></span></span>
                                        <span style="color: black"><span style="font-size: 10pt; font-family: Arial">from </span><asp:DropDownList
                                            ID="ddlOrigin" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlOrigin_SelectedIndexChanged">
                                            <asp:ListItem Value="MNL">Manila</asp:ListItem>
                                            <asp:ListItem Value="CEB">Cebu</asp:ListItem>
                                            <asp:ListItem Value="ZAM">Zamboanga</asp:ListItem>
                                        </asp:DropDownList>
                                            to
                                            <asp:DropDownList ID="ddlArrival" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlArrival_SelectedIndexChanged">
                                                <asp:ListItem Value="MNL">Manila</asp:ListItem>
                                                <asp:ListItem Value="CEB">Cebu</asp:ListItem>
                                                <asp:ListItem Value="ZAM">Zamboanga</asp:ListItem>
                                            </asp:DropDownList>
                                            <asp:ImageButton ID="imgNextDayDepart" runat="server" ImageUrl="~/Images/NEXTDAY.PNG" OnClick="imgNextDayDepart_Click" /></span><table style="border: #cccccc 1px solid;width: 883px; height: 165px;">
                                    <tr>
                                        <td style="background-color: #fff68f; height: 4px;" colspan="3">
                                            <span style="font-family: Arial">
                                                <asp:Label ID="lblDepartDate" runat="server" Text="Date : "></asp:Label></span></td>
                                        <td style="background-color: #ffee8b; height: 4px; font-size: 10pt;" colspan="2">
                                            <span style="font-family: Arial">GO FARE</span></td>
                                        <td style="background-color: #ffa73e; height: 4px; width: 364px;" colspan="2">
                                            <span style="font-size: 10pt; font-family: Arial">PROMO FARE</span></td>
                                    </tr>
                                </table>
                                <asp:PlaceHolder ID="c_departure" runat="server"></asp:PlaceHolder>
                                        <br />
                                        <table style="width: 889px;">
                                            <tr>
                                                <td colspan="5" style="text-align: center; height: 55px;" valign="middle">
                                <table style="width: 887px">
                                    <tr>
                                        <td style="width: 84px">
                                            </td>
                                        <td style="width: 679px">
                                        </td>
                                        <td style="width: 99px">
                                            </td>
                                    </tr>
                                </table><hr style="color: #cd9a67; height: 1px;" />
                                            <asp:ImageButton ID="imgPreviousDayReturn" runat="server" ImageUrl="~/Images/PREVDAY.PNG" OnClick="imgPreviousDayReturn_Click" />RETURN OPTIONS from
                                                    <asp:Label ID="lblDestination" runat="server"></asp:Label>
                                                    to
                                                    <asp:Label ID="lblOrigin" runat="server"></asp:Label>
                                            <asp:ImageButton ID="imgNextDayReturn" runat="server" ImageUrl="~/Images/NEXTDAY.PNG" OnClick="imgNextDayReturn_Click" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="5" style="text-align: left; height: 6px;" valign="middle">
                                <span style="font-size: 10pt"><span style="font-family: Arial"><strong><span style="color: #ff0000">
                                    </span></strong><span style="color: black">
                                        <br />
                                        <table style="width: 889px;">
                                            <tr>
                                                <td colspan="5" style="text-align: center; height: 56px;" valign="middle">
                                <table style="border: #cccccc 1px solid;width: 883px; height: 165px;">
                                    <tr>
                                        <td style="background-color: #fff68f; height: 1px;" colspan="3">
                                            <span style="font-family: Arial">
                                                <asp:Label ID="lblReturnDate" runat="server" Text="Date : "></asp:Label></span></td>
                                        <td style="background-color: #ffee8b; height: 1px;" colspan="2">
                                            <span style="font-size: 10pt; font-family: Arial">GO FARE</span></td>
                                        <td style="background-color: #ffa73e; height: 1px;" colspan="2">
                                            <span style="font-size: 10pt; font-family: Arial">PROMO FARE</span></td>
                                    </tr>
                                </table>
                                <asp:PlaceHolder ID="c_return" runat="server"></asp:PlaceHolder>
                                                    <br />
                                                    <table style="width: 889px;">
                                                        <tr>
                                                            <td colspan="5" style="text-align: center" valign="middle">
                                <table style="width: 887px">
                                    <tr>
                                        <td style="width: 84px">
                                            </td>
                                        <td style="width: 679px">
                                            <asp:Button ID="btnSelect" runat="server" Text="Continue" Width="80px" OnClick="btnSelect_Click"  />
                                            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></td>
                                        <td style="width: 99px">
                                            </td>
                                    </tr>
                                </table><hr style="color: #cd9a67; height: 1px;" />
                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </span></span></span></td>
                                            </tr>
                                        </table>
                                    </ContentTemplate>
                                    <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="imgNextDayDepart" EventName="Click" />
                                    <asp:AsyncPostBackTrigger ControlID="imgNextDayReturn" EventName="Click" />
                                    <asp:AsyncPostBackTrigger ControlID="imgPreviousDayDepart" EventName="Click" />
                                    <asp:AsyncPostBackTrigger ControlID="imgPreviousDayReturn" EventName="Click" />
                                    <asp:AsyncPostBackTrigger ControlID="btnSelect" EventName="Click" />
                                    
                                    
                                    
                                    
                                    </Triggers>
                                </asp:UpdatePanel>
                                 
                            </td>
                        </tr>
                        <tr>
                            <td colspan="5" style="text-align: center" valign="middle">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="5" style="text-align: left; height: 6px;" valign="middle">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="5" style="text-align: center; height: 56px;" valign="middle">
                                            </td>
                        </tr>
                        <tr>
                            <td colspan="5" style="text-align: center" valign="middle">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="5" style="text-align: center; height: 161px;" valign="middle">
                                <table style="width: 887px">
                                    <tr>
                                        <td colspan="2" style="text-align: left">
                                            <strong><span style="font-size: 10pt; color: #ff0000; font-family: Arial">FARE RULES</span></strong></td>
                                        <td style="width: 428px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" style="text-align: left">
                                            </td>
                                        <td style="width: 428px">
                                            </td>
                                    </tr>
                                    <tr>
                                        <td colspan="3" style="text-align: left">
                                            <asp:CheckBox ID="CheckBox1" runat="server" Width="16px" />
                                            <span style="font-size: 10pt; font-family: Arial">I have read and accept the fare rule,
                                                <span style="text-decoration: underline"><em><strong>general terms and condition</strong></em></span>,
                                                <span style="text-decoration: underline"><strong><em>travel requlation</em></strong></span>,
                                                <strong><em><span style="text-decoration: underline">website terms of use</span></em></strong>
                                                and important reminders and information posted bu the airline. I will advise all
                                                other guests travelling as part of this booking of these conditions.</span></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3" style="text-align: right">
                                            </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                </td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>

CODE BEHIND

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Collections.Generic;

public partial class Default : System.Web.UI.Page
{
    //Assign values as a specific Dynamic WebControl Creation.
    List<RadioButton> radioButtons = new List<RadioButton>();
    List<CheckBox> checkBoxes = new List<CheckBox>();

    protected void Page_Init(object sender, EventArgs e)
    {
        //TEST AREA
        Session["TripType"] = "Round Trip";
        Session["FlightCode"] = "MNL/CEB";
        Session["DepartOrigin"] = "6/24/2010";
        Session["DepartReturn"] = "6/25/2010";


        if (IsPostBack)
        {

        }
        else if (!IsPostBack)
        {

            CallPageLoad();
        }
    }



    protected void imgNextDayDepart_Click(object sender, ImageClickEventArgs e)
    {
        string departdate = Convert.ToString(Session["DepartOrigin"]);
        string returndate = Convert.ToString(Session["DepartReturn"]);
        DateTime realformatdepartdate;
        DateTime realformatreturndate;
        realformatdepartdate = Convert.ToDateTime(departdate);
        realformatreturndate = Convert.ToDateTime(returndate);

        //DESC : 
        //Uninterrupted method == (ADD 1 DAY)
        realformatdepartdate = realformatdepartdate.AddDays(1);
        Session["DepartOrigin"] = realformatdepartdate;
        lblDepartDate.Text = realformatdepartdate.ToLongDateString();


        //Conditional == (ADD 1 DAY TO RETURN DAY)Because returndate must not be less than departdate.
        if (realformatdepartdate > realformatreturndate)
        {
            //realformatdepartdate = realformatdepartdate.AddDays(1);
            //Session["DepartOrigin"] = realformatdepartdate;
            realformatreturndate = realformatreturndate.AddDays(1);
            Session["DepartReturn"] = realformatreturndate;
            lblReturnDate.Text = realformatreturndate.ToLongDateString();
            //Response.Redirect("SelectFlightCopy.aspx");
        }
        //Response.Redirect("SelectFlightCopy.aspx");

        CallPageLoad();
    }

    protected void imgPreviousDayReturn_Click(object sender, ImageClickEventArgs e)
    {
        string departdate = Convert.ToString(Session["DepartOrigin"]);
        string returndate = Convert.ToString(Session["DepartReturn"]);
        DateTime realformatdepartdate;
        DateTime realformatreturndate;
        realformatdepartdate = Convert.ToDateTime(departdate);
        realformatreturndate = Convert.ToDateTime(returndate);
        DateTime now;
        now = Convert.ToDateTime(DateTime.Today);

        if (realformatreturndate == now)
        {
            Image stop = new Image();
            stop.ImageUrl = "Images/stop.gif";
            stop.Height = new Unit("20");
            stop.Width = new Unit("20");
            c_return.Controls.Add(stop);

            Label informant = new Label();
            informant.Text = "Sorry, you can no longer access flights from yesterday and beyond..";
            c_return.Controls.Add(informant);
        }
        else
        {
            realformatreturndate = realformatreturndate.AddDays(-1);
            lblReturnDate.Text = realformatreturndate.ToLongDateString();
            Session["DepartReturn"] = realformatreturndate;
            //Response.Redirect("SelectFlightCopy.aspx");
        }

        if (realformatreturndate < realformatdepartdate)
        {
            //realformatdepartdate = realformatdepartdate.AddDays(1);
            //Session["DepartOrigin"] = realformatdepartdate;
            realformatdepartdate = realformatdepartdate.AddDays(-1);
            Session["DepartOrigin"] = realformatdepartdate;
            lblDepartDate.Text = realformatdepartdate.ToLongDateString();
            //Response.Redirect("SelectFlightCopy.aspx");
        }
        CallPageLoad();

    }
    protected void imgPreviousDayDepart_Click(object sender, ImageClickEventArgs e)
    {
        string departdate = Convert.ToString(Session["DepartOrigin"]);
        string returndate = Convert.ToString(Session["DepartReturn"]);
        DateTime realformatdepartdate;
        DateTime realformatreturndate;
        realformatdepartdate = Convert.ToDateTime(departdate);
        realformatreturndate = Convert.ToDateTime(returndate);
        DateTime now;
        now = Convert.ToDateTime(DateTime.Today);


        if (realformatdepartdate == now)
        {
            Image stop = new Image();
            stop.ImageUrl = "Images/stop.gif";
            stop.Height = new Unit("20");
            stop.Width = new Unit("20");
            c_departure.Controls.Add(stop);


            Label informant = new Label();
            informant.Text = "Sorry, you can no longer access flights from yesterday and beyond..";
            c_departure.Controls.Add(informant);
        }
        else
        {


            realformatdepartdate = realformatdepartdate.AddDays(-1);
            lblDepartDate.Text = realformatdepartdate.ToLongDateString();
            Session["DepartOrigin"] = realformatdepartdate;
            //Response.Redirect("SelectFlightCopy.aspx");
        }
        CallPageLoad();

    }
    protected void imgNextDayReturn_Click(object sender, ImageClickEventArgs e)
    {
        string departdate = Convert.ToString(Session["DepartOrigin"]);
        string returndate = Convert.ToString(Session["DepartReturn"]);
        DateTime realformatdepartdate;
        DateTime realformatreturndate;
        realformatdepartdate = Convert.ToDateTime(departdate);
        realformatreturndate = Convert.ToDateTime(returndate);
        DateTime now;
        now = Convert.ToDateTime(DateTime.Today);

        realformatreturndate = realformatreturndate.AddDays(1);
        lblReturnDate.Text = realformatreturndate.ToLongDateString();
        Session["DepartReturn"] = realformatreturndate;

        //Response.Redirect("SelectFlightCopy.aspx");
        CallPageLoad();

    }

    protected void ddlOrigin_SelectedIndexChanged(object sender, EventArgs e)
    {

        Session["FlightCode"] = ddlOrigin.SelectedValue.ToString() + "/" + ddlArrival.SelectedValue.ToString();
        Response.Redirect("SelectFlightCopy.aspx");
    }
    protected void ddlArrival_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["FlightCode"] = ddlOrigin.SelectedValue.ToString() + "/" + ddlArrival.SelectedValue.ToString();
        Response.Redirect("SelectFlightCopy.aspx");
    }
    public void CallPageLoad()
    {



        if (Session["TripType"] == "" | Session["TripType"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        //FETCH SESSIONS
        string triptype = Convert.ToString(Session["TripType"]);
        string flightcode = Convert.ToString(Session["FlightCode"]);//SET AS PK

        string departdate = Convert.ToString(Session["DepartOrigin"]);
        string returndate = Convert.ToString(Session["DepartReturn"]);
        DateTime realformatdepartdate = DateTime.Parse(departdate);
        DateTime realformatreturndate = DateTime.Parse(returndate);
        realformatdepartdate = Convert.ToDateTime(departdate);
        realformatreturndate = Convert.ToDateTime(returndate);


        //Response.Write("You are interested in a " + triptype + flightcode + " flight. <br/> You will leave at " + realformatdepartdate.ToShortDateString() + " and you will return this coming " + realformatreturndate.ToShortDateString());
        //Auto Generate Return Code
        string[] fcarray = flightcode.Split('/');
        string fc1 = fcarray[0];
        string fc2 = fcarray[1];
        string flightcode2 = fcarray[1] + "/" + fcarray[0];
        string translatedfc1 = "", translatedfc2 = "";
        int ColorKey1 = 0;
        int ColorKey2 = 0;


        //ORIGIN AND DESTINATION INFORMANT
        lblDepartDate.Text = realformatdepartdate.ToLongDateString();
        lblReturnDate.Text = realformatreturndate.ToLongDateString();

        //Flight code markup translation space
        switch (fc1)
        {
            case "MNL":
                translatedfc1 = "Manila";
                break;
            case "CEB":
                translatedfc1 = "Cebu";
                break;
            case "ZAM":
                translatedfc1 = "Zamboanga";
                break;
            default:
                break;
        }
        switch (fc2)
        {
            case "MNL":
                translatedfc2 = "Manila";
                break;
            case "CEB":
                translatedfc2 = "Cebu";
                break;
            case "ZAM":
                translatedfc2 = "Zamboanga";
                break;
            default:
                break;
        }
        ddlOrigin.SelectedValue = fc1;
        ddlArrival.SelectedValue = fc2;



        //Response.Write("<br/>point 1 is from " + fc1 + " and point 2 is from " + fc2);

        //Response.Write("<br/> auto generated return code is " + flightcode2);

        //Connect to Database
        XmlDocument xd = new XmlDocument();
        xd.Load(Server.MapPath("App_Data/FlightDates.xml"));
        //load document
        XmlNodeList xnl = xd.SelectSingleNode("Flights").ChildNodes;
        int RadioBtnCount = 0;
        //select a single node, assign xnl as (Flights)
        foreach (XmlNode xn in xnl)
        //for each XML node in Flights
        {
            XmlElement xe = (XmlElement)xn;
            //assign XE as shortcut for XMLElement. XE is equal to XML Element of XML Node
            XmlNodeList dfc = xe.GetElementsByTagName("FlightCode");
            XmlNodeList dfn = xe.GetElementsByTagName("FlightNumber");
            XmlNodeList dfd = xe.GetElementsByTagName("FlightDate");
            XmlNodeList seats = xe.GetElementsByTagName("Seats");
            XmlNodeList detd = xe.GetElementsByTagName("FlightETD");
            XmlNodeList deta = xe.GetElementsByTagName("FlightETA");
            XmlNodeList drurl = xe.GetElementsByTagName("RuleURL");
            XmlNodeList dcostb = xe.GetElementsByTagName("CostBags");
            XmlNodeList dcostwob = xe.GetElementsByTagName("CostWOBags");
            //elements now assigned.

            //Global RadioButtonList Space
            //RadioButtonList WFares = new RadioButtonList();
            RadioButton WFaresBags = new RadioButton();
            RadioButton WFaresWOBags = new RadioButton();
            WFaresBags.ID = "rblFaresBags";
            WFaresWOBags.ID = "rblFaresBags";

            CheckBox checkedbags = new CheckBox();

            //btnSelect_OnClick
            Table Table1 = new Table();

            for (int i = 0; i < dfc.Count; i++)
            {
                if (dfc[i].InnerText == flightcode && dfd[i].InnerText == Convert.ToString(realformatdepartdate.ToShortDateString()))
                {
                    //Response.Write("<br/>Flight Code : " + dfc[i].InnerText + "</br>Flight Number : " + dfn[i].InnerText + "<br/>Flight Date : " + dfd[i].InnerText + "<br/>Seats : " + seats[i].InnerText);
                    Session["FoundResult"] = 1;
                    int createrow = 1;
                    int createcolumn = 1;

                    for (int j = 0; j < createrow; j++)
                    {
                        //System.Web.UI.WebControls.RadioButtonList ButtonListFlights = new System.Web.UI.WebControls.RadioButtonList();
                        //ButtonListFlights.ID = "rblFares";

                        TableRow r = new TableRow();
                        for (int d = 0; d < createcolumn; d++)
                        {
                            System.Web.UI.WebControls.Label from = new System.Web.UI.WebControls.Label();
                            from.Text = translatedfc1 + "     to        " + translatedfc2 + "<br/> Flight Number : " + dfn[i].InnerText + "</br> Seats Available : " + seats[i].InnerText + "<br/>";

                            //ETD
                            System.Web.UI.WebControls.Image etdimg = new System.Web.UI.WebControls.Image();
                            etdimg.ImageUrl = "Images/time.jpg";
                            etdimg.ToolTip = "Estimated Departure Time";
                            etdimg.Height = new Unit("20");
                            etdimg.Width = new Unit("20");
                            //

                            //TIME 1
                            System.Web.UI.WebControls.Label etd = new System.Web.UI.WebControls.Label();
                            etd.Text = detd[i].InnerText;
                            etd.ToolTip = "Estimated Departure Time";

                            //SPLITTER
                            System.Web.UI.WebControls.Label splitter = new System.Web.UI.WebControls.Label();
                            splitter.Font.Size = new FontUnit("20");
                            splitter.Text = " |";
                            //


                            //ETA IMAGE 
                            System.Web.UI.WebControls.Image etaimg = new System.Web.UI.WebControls.Image();
                            etaimg.ImageUrl = "Images/time2.jpg";
                            etaimg.ToolTip = "Estimated Time of Arrival";
                            etaimg.Height = new Unit("20");
                            etaimg.Width = new Unit("20");
                            System.Web.UI.WebControls.Label eta = new System.Web.UI.WebControls.Label();
                            eta.Text = deta[i].InnerText + "   ";
                            eta.ToolTip = "Estimated Time of Arrival";
                            //
                            //VIEW RULES
                            System.Web.UI.HtmlControls.HtmlAnchor departurerules = new System.Web.UI.HtmlControls.HtmlAnchor();
                            departurerules.HRef = "Rules/" + drurl[i].InnerText + ".html?KeepThis=true&TB_iframe=true&height=400&width=600";
                            departurerules.InnerText = "View Rules";
                            departurerules.Style.Add("font-size", "10");
                            departurerules.Attributes.Add("class", "thickbox");
                            departurerules.Title = "Flight " + dfn[i].InnerText + " Rules";
                            //


                            TableCell c = new TableCell();
                            c.Controls.Add(from);
                            c.Controls.Add(etdimg);
                            c.Controls.Add(etd);
                            c.Controls.Add(splitter);
                            c.Controls.Add(etaimg);
                            c.Controls.Add(eta);
                            c.Controls.Add(departurerules);
                            c.Width = new Unit("310");
                            c.Height = new Unit("56");
                            c.BorderStyle = BorderStyle.Dashed;
                            //CELL COLOR SPACE
                            ColorKey1++;
                            string colortrigger = "";
                            if (ColorKey1 % 2 == 0)
                            {
                                colortrigger = "#CCCC99";
                            }
                            else
                            {
                                colortrigger = "#CCFF99";
                            }
                            System.Drawing.ColorConverter colConvert = new System.Drawing.ColorConverter();
                            c.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(colortrigger);

                            r.Cells.Add(c);

                        }


                        //FARE SELECTOR

                        for (int d = 0; d < createcolumn; d++)
                        {
                            WFaresBags.ID = "rb" + dfn[i].InnerText.ToString() + "BagsDeparting";
                            WFaresBags.GroupName = "rblFaresDeparting";
                            RadioBtnCount++;
                            //WFares = new RadioButtonList();
                            WFaresBags.Text = dcostb[i].InnerText + "(w/checked bags)<br/>";
                            //WFares.Items.Add(new ListItem(dcostb[i].InnerText, dfn[i].InnerText)); 
                            TableCell c = new TableCell();
                            c.Controls.Add(WFaresBags);

                            WFaresWOBags.ID = "rb" + dfn[i].InnerText.ToString() + "NoBagsDeparting";
                            WFaresWOBags.GroupName = "rblFaresDeparting";
                            RadioBtnCount++;
                            //WFares = new RadioButtonList();
                            WFaresWOBags.Text = dcostwob[i].InnerText + "(w/out checked bags)";
                            //WFares.Items.Add(new ListItem(dcost[i].InnerText, dfn[i].InnerText)); 
                            c.Controls.Add(WFaresWOBags);


                            c.BorderStyle = BorderStyle.Dashed;
                            ColorKey2++;
                            string colortrigger = "";
                            if (ColorKey2 % 2 == 0)
                            {
                                colortrigger = "#CCCCCC";
                            }
                            else
                            {
                                colortrigger = "#CCFFCC";
                            }
                            System.Drawing.ColorConverter colConvert = new System.Drawing.ColorConverter();
                            c.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(colortrigger);

                            r.Cells.Add(c);
                        }
                        Table1.Rows.Add(r);

                        c_departure.Controls.Add(Table1);

                        //Add WFares to our Globally assigned Dynamic RadioButton WebControl
                        radioButtons.Add(WFaresBags);
                        radioButtons.Add(WFaresWOBags);
                        checkBoxes.Add(checkedbags);


                    }//Results found for our departure flights.

                }



                if (dfc[i].InnerText == flightcode2 && dfd[i].InnerText == Convert.ToString(realformatreturndate.ToShortDateString()))
                {
                    int createrow = 1;
                    int createcolumn = 1;

                    for (int j = 0; j < createrow; j++)
                    {
                        //System.Web.UI.WebControls.RadioButtonList ButtonListFlights = new System.Web.UI.WebControls.RadioButtonList();
                        //ButtonListFlights.ID = "rblFares";

                        TableRow r = new TableRow();
                        for (int d = 0; d < createcolumn; d++)
                        {
                            System.Web.UI.WebControls.Label from = new System.Web.UI.WebControls.Label();
                            from.Text = translatedfc2 + "     to        " + translatedfc1 + "<br/> Flight Number : " + dfn[i].InnerText + "</br> Seats Available : " + seats[i].InnerText + "<br/>";



                            //ETD
                            System.Web.UI.WebControls.Image etdimg = new System.Web.UI.WebControls.Image();
                            etdimg.ImageUrl = "Images/time.jpg";
                            etdimg.ToolTip = "Estimated Departure Time";
                            etdimg.Height = new Unit("20");
                            etdimg.Width = new Unit("20");
                            //

                            //TIME 1
                            System.Web.UI.WebControls.Label etd = new System.Web.UI.WebControls.Label();
                            etd.Text = detd[i].InnerText;
                            etd.ToolTip = "Estimated Departure Time";

                            //SPLITTER
                            System.Web.UI.WebControls.Label splitter = new System.Web.UI.WebControls.Label();
                            splitter.Font.Size = new FontUnit("20");
                            splitter.Text = " |";
                            //


                            //ETA IMAGE 
                            System.Web.UI.WebControls.Image etaimg = new System.Web.UI.WebControls.Image();
                            etaimg.ImageUrl = "Images/time2.jpg";
                            etaimg.ToolTip = "Estimated Time of Arrival";
                            etaimg.Height = new Unit("20");
                            etaimg.Width = new Unit("20");
                            System.Web.UI.WebControls.Label eta = new System.Web.UI.WebControls.Label();
                            eta.Text = deta[i].InnerText + "   ";
                            eta.ToolTip = "Estimated Time of Arrival";
                            //
                            //VIEW RULES
                            System.Web.UI.HtmlControls.HtmlAnchor departurerules = new System.Web.UI.HtmlControls.HtmlAnchor();
                            departurerules.HRef = "Rules/" + drurl[i].InnerText + ".html?KeepThis=true&TB_iframe=true&height=400&width=600";
                            departurerules.InnerText = "View Rules";
                            departurerules.Style.Add("font-size", "10");
                            departurerules.Attributes.Add("class", "thickbox");
                            departurerules.Title = "Flight " + dfn[i].InnerText + " Rules";
                            //

                            TableCell c = new TableCell();
                            c.Controls.Add(from);
                            c.Controls.Add(etdimg);
                            c.Controls.Add(etd);
                            c.Controls.Add(splitter);
                            c.Controls.Add(etaimg);
                            c.Controls.Add(eta);
                            c.Controls.Add(departurerules);
                            c.Width = new Unit("310");
                            c.Height = new Unit("56");
                            c.BorderStyle = BorderStyle.Dashed;
                            //CELL COLOR SPACE
                            ColorKey1++;
                            string colortrigger = "";
                            if (ColorKey1 % 2 == 0)
                            {
                                colortrigger = "#CCCC99";
                            }
                            else
                            {
                                colortrigger = "#CCFF99";
                            }
                            System.Drawing.ColorConverter colConvert = new System.Drawing.ColorConverter();
                            c.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(colortrigger);

                            r.Cells.Add(c);

                        }

                        //FARE SELECTOR

                        for (int d = 0; d < createcolumn; d++)
                        {
                            WFaresBags.ID = "rb" + dfn[i].InnerText.ToString() + "BagsReturning";
                            WFaresBags.GroupName = "rblFaresReturning";
                            WFaresBags.CausesValidation = true;
                            RadioBtnCount++;
                            //WFares = new RadioButtonList();
                            WFaresBags.Text = dcostb[i].InnerText + "(w/checked bags)<br/>";
                            //WFares.Items.Add(new ListItem(dcostb[i].InnerText, dfn[i].InnerText)); 
                            TableCell c = new TableCell();
                            //ScriptManager.RegisterAsyncPostBackControl(WFaresBags);
                            c.Controls.Add(WFaresBags);

                            WFaresWOBags.ID = "rb" + dfn[i].InnerText.ToString() + "NoBagsReturning";
                            WFaresWOBags.GroupName = "rblFaresReturning";

                            RadioBtnCount++;
                            //WFares = new RadioButtonList();
                            WFaresWOBags.Text = dcostwob[i].InnerText + "(w/out checked bags)";
                            //WFares.Items.Add(new ListItem(dcost[i].InnerText, dfn[i].InnerText)); 
                            c.Controls.Add(WFaresWOBags);


                            c.BorderStyle = BorderStyle.Dashed;
                            ColorKey2++;
                            string colortrigger = "";
                            if (ColorKey2 % 2 == 0)
                            {
                                colortrigger = "#CCCCCC";
                            }
                            else
                            {
                                colortrigger = "#CCFFCC";
                            }
                            System.Drawing.ColorConverter colConvert = new System.Drawing.ColorConverter();
                            c.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(colortrigger);

                            r.Cells.Add(c);



                        }


                        Table1.Rows.Add(r);

                        c_return.Controls.Add(Table1);


                        //Add WFares to our Globally assigned Dynamic RadioButton WebControl


                        radioButtons.Add(WFaresBags);
                        radioButtons.Add(WFaresWOBags);
                        checkBoxes.Add(checkedbags);

                        //if (Request["btnSelect"] != null)
                        //{
                        //}
                    }



                }//

            }
        }

        //RETURN OPTIONS AUTO STATIC INFORMANT
        lblOrigin.Text = translatedfc1;
        lblDestination.Text = translatedfc2;
        //if (notfoundtoday == 1)
        //{
        //    realformatreturndate = realformatreturndate.AddDays(1);
        //    Session["DepartReturn"] = realformatreturndate;
        //    Response.Redirect("SelectFlightCopy.aspx");
        //}
        //if (Request["btnSelect"] != null)
        //{
        //    foreach (RadioButton button in radioButtons)
        //    {
        //        if (button.Checked == true)
        //        {
        //            lblDepartDate.Text = "YAHOOOO!!!!!!";



        //        }
        //    }


        //}
    }


    protected void btnSelect_Click(object sender, EventArgs e)
    {



        CallPageLoad();
        //IF WE ENABLE THIS SINGLE CODE BELOW, IT COULD DETECT THE RADIOBUTTONS
        Label1.Text = Convert.ToString(radioButtons.Count);



        //BUT THIS CODE BELOW, WHEN WE TRY TO ENABLE IT, IT WONT DETECT THE CHECKED BUTTONS...
        //PLS HELP.......
        foreach (RadioButton button in radioButtons)
        {
            if (button.Checked == true)
            {
                Label1.Text = "You select... " +  button.ID;
                
                CallPageLoad();
            }

        }

    }

}

I want line 637 to work (CODE BEHIND) and tried lots of workaround but I just can't get it to work...

Here's the full source code.. please scan it for your safety.
http://www.mediafire.com/?nh14oi1mmeo

Edited by cafekko: n/a

3
Contributors
8
Replies
10
Views
7 Years
Discussion Span
Last Post by Lusiphur
1

I can't help wondering if this is a similar issue to the one I was having with dynamically populated ListBox controls losing their databinds during postbacks.

I will admit, I only skimmed through your code and there is so much going on dynamically that it's hard to say. My thought is that when the radio buttons are dynamically loaded the first time around and then selected... and then the load process is repeated (on call of CallPageLoad()) it may be changing the values of the radioboxes or losing the selected values in the re-processing of the dynamic content.

Perhaps there is some way you can trigger your responses without re-loading the entire process such that the original data is preserved?

Again I could be way off-base here and feel free to completely ignore me lol :P

0

i'll try to encapsulate the functions inside CallPageLoad()! Thanks for giving me this idea. I'll mark your post useful if ever I get a workaround on this one. Thanks and good day!

0

Just to clarify, if you can separate your databinds from your selection processes such that the databinds happen once and the selection processes don't repeat the binds unnecessarily I think this might solve your problem.

However, I've spent the last 4 days putting in 12-14 hour days of coding on a C# ASP.Net project of my own and my brain isn't working at peak at the moment ;)

0

Noted. Thanks man. To tell you honestly, the stress is taking its toll over me. I've got so many pending projects and this is one of them. See ya around.

1

Another possibility is to add a RadioButtonList, with visible=false into the .aspx in the place where you want the RadioButtons to be.
Then I think dynamically adding the radio buttons (and visible="true") to that existing list will work.

Edited by mikev2: n/a

0

Hmm... this went from solved to unsolved (it was flagged solved earlier) for no apparent reason :P

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.