I have to fill a list box with some values.. Select a value. As soon as i select i should get another dropdown list containing values related to the selected value. And after i select a value from the second dropdown i have to display something on the same page related to the second value selected. I am getting the first dropdown.selectedindexchanged event handled properly. But the second dropdown event handler is not getting called. I have put the loading of first dropdown in page_load event and given a separate event handler for each dropdown. In first handler i get the selected value and display the second dropdown. In the same event if i lauch the second event handler it goes back and loads the page again with only the first dropdown. Give me some solution.
Putting these things in Page_load is wrong?
Loading
RakrusPosted Feb 14, 2008, 11:27 PM
Page_Load
{
//sel_val = ((DropDownList)s).SelectedValue;
sel_val = d1.SelectedValue;
filter_lov = new DropDownList();
Value[] lovs = (Value[])Filters[sel_val];
filter_lov.Items.Add(new ListItem("Select a value.."));
for (int i = 0; i < lovs.Length; i++)
{
filter_lov.Items.Add(new ListItem(lovs[i].Columns[0].ToString()));
}
Place1.Controls.Add(new LiteralControl(sel_val+":"));
filter_lov.Visible = true;
Place1.Controls.Add(filter_lov);
filter_lov.AutoPostBack = true;
filter_lov.SelectedIndexChanged+= new EventHandler(filter_lov_SelectedIndexChanged);
}
d1_selChange
{
filters_loaded = true;
}
MonicaPosted Feb 14, 2008, 11:05 PM
MonicaPosted Feb 14, 2008, 10:39 PM
RakrusPosted Feb 14, 2008, 10:28 PM
Hi Monica,
Move the code from d1_selectionChnaged to Page_Load,any way you have a check in the d1 handle.
Thanks
MonicaPosted Feb 14, 2008, 8:24 AM
using System.Data;
using System.Configuration;
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.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Net;
using System.Text;
using BusinessObjects.DSWS.ReportEngine;
using BusinessObjects.DSWS.Session;
using BusinessObjects.DSWS.BIPlatform;
public partial class _Default : System.Web.UI.Page
{
public static DocumentInformation docInfo = null;
public static DrillDimension[] FreeDimensions = null;
public static DrillInfo drillInfo= null;
public static string ReportID;
public static string sel_filter;
public static string sel_lov;
public static Hashtable Filters;
public static Hashtable Filter_ID;
public static DropDownList d1=null;
public static DropDownList filter_lov = null;//new DropDownList();
public static string sel_val;
public static bool report_loaded = false;
public static bool filters_loaded = false;
protected void Page_Load(object sender, EventArgs e)
{
string DocName = "Effective Full License";
string DocPath = @"path://*/**/";
ReportID = RetrieveDocIDByPath(DocPath + DocName);
Console.WriteLine(ReportID);
docInfo = GetDocInfo(ReportID, null);
drillInfo = docInfo.DrillInfo;
if (d1 == null)
d1 = new DropDownList();
if (d1.Items.Count == 0)
{
//string[] lov_val = null;
Filters = new Hashtable();
Filter_ID = new Hashtable();
if (drillInfo != null)
{
FreeDimensions = drillInfo.FreeDrillDimensions;
foreach (DrillDimension dim in FreeDimensions)
{
Value[] values = dim.LOV.Values;
ArrayList valuesList = new ArrayList();
foreach (Value val in values)
{
valuesList.Add(val.Columns[0]);
//lov_val[i++] = val.Columns[0]
}
Filters.Add(dim.Name, values);
Filter_ID.Add(dim.Name, dim.ID);
}
}
if (!IsPostBack)
{
d1.Items.Add(new ListItem("Select filter..."));
foreach (DictionaryEntry entry in Filters)
{
d1.Items.Add(new ListItem(entry.Key.ToString()));
}
d1.Visible = true;
}
}
Place1.Controls.Add(new LiteralControl("Filters: "));
Place1.Controls.Add(d1);
d1.AutoPostBack = true;
d1.SelectedIndexChanged += new EventHandler(d1_SelectedIndexChanged);
if (filters_loaded)
{
filter_lov.AutoPostBack = true;
//filter_lov.SelectedIndex = 3;
//d1.AutoPostBack = false;
filter_lov.SelectedIndexChanged += new EventHandler(filter_lov_SelectedIndexChanged);
// Response.Redirect("http://localhost:2328/Filters/Default2.aspx?__filterval=" + HttpUtility.UrlEncode(sel_val) + "&__filterid=" + HttpUtility.UrlEncode(Filter_ID[sel_val].ToString())+"&__filter="+HttpUtility.UrlEncode(filter_lov.SelectedValue));
}
}
public void d1_SelectedIndexChanged(object s, EventArgs y)
{
sel_val = ((DropDownList)s).SelectedValue;
filter_lov = new DropDownList();
Value[] lovs = (Value[])Filters[sel_val];
filter_lov.Items.Add(new ListItem("Select a value.."));
for (int i = 0; i < lovs.Length; i++)
{
filter_lov.Items.Add(new ListItem(lovs[i].Columns[0].ToString()));
}
Place1.Controls.Add(new LiteralControl(sel_val+":"));
filter_lov.Visible = true;
Place1.Controls.Add(filter_lov);
filter_lov.AutoPostBack = true;
filters_loaded = true;
filter_lov.SelectedIndexChanged+= new EventHandler(filter_lov_SelectedIndexChanged);
}
public void filter_lov_SelectedIndexChanged(object sender, EventArgs e)
{
sel_lov = filter_lov.SelectedValue;
// Response.Redirect("http://localhost:2328/Filters/Default2.aspx?__filterval=" + HttpUtility.UrlEncode(sel_val) + "&__filterid=" + HttpUtility.UrlEncode(Filter_ID[sel_val].ToString()));
Drill boDrill = new Drill();
boDrill.ActiveDrill = true;
DrillPath boDrillPath = new DrillPath();
//block is a report element e.g a table, chart etc.
boDrillPath.BlockID = "0";
//Drill down in the document
boDrillPath.DrillOperationType = DrillOperationType.SLICE;
boDrillPath.FromObjectID = new string[] { Filter_ID[sel_val].ToString() };
//Value[] lov = dim[0].LOV.Values;
string[] setFilter = { sel_lov };
boDrillPath.Filter = setFilter;
Action[] actions = new Action[1];
boDrill.DrillPath = boDrillPath;
actions[0] = boDrill;
docInfo = GetDocInfo(ReportID, actions);
Response.Write(((CharacterView)docInfo.View).Content);
report_loaded = false;
}
/**************************/
Rest of the code
RakrusPosted Feb 14, 2008, 6:03 AM
Hi Monica,
Try this,
Page_Load()
{
if(!IsPostback)
{
// first dropdown binding goes here
}
}
I think this is what you missed.If not pls send the code for further help.
Thanks