how to display data in listbox control from a query string
Hello,
I have a scenario in which There is a web form with tree view control.
This tree view control has check boxes. and some text (like name of nodes)
Now when user selects more than one check boxes (ultimately he selects more than one nodes) and press on Ok Button
the page will transfer to another page where there is a listbox control.
In this list box control the name of selected nodes will display.
I did the same for single node, but when I tried to select more than one node it does not show me more than one node's name in the list box.
my code for tree view calss is as below:
private void Filldata(TreeNode parent)
{
string connection = System.Configuration.ConfigurationManager.AppSettings["HTMSConnectionString"];
string csp = System.Configuration.ConfigurationManager.AppSettings["spAllGroupsLoadTree"];
DataSet ds = SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, csp);
foreach (DataRow row in ds.Tables[0].Rows)
{
TreeNode node = new TreeNode();
node.Text = row["GroupName"].ToString();
node.Value = row["GroupID"].ToString();
node.PopulateOnDemand = true;
node.SelectAction = TreeNodeSelectAction.SelectExpand;
// node.ChildNodes.Add(parent);
parent.ChildNodes.Add(node);
// Filldata(parent.ChildNodes[0]);
}
}
protected void trv_SelectGroups_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
if (e.Node.ChildNodes.Count == 0)
{
if (e.Node.Depth == 0)
{
Filldata(e.Node);
}
}
}
protected void cmdCheckSelectNode_Click(object sender, EventArgs e)
{
if (trv_SelectGroups.CheckedNodes.Count > 0)
{
foreach (TreeNode node in trv_SelectGroups.CheckedNodes)
{
// Server.Transfer("~/WUI/rpt_view_JobsCompleted.aspx? param1=" + year1 + "& paramE=" + year2, true);
Server.Transfer("~/WUI/TerminalSearch.aspx?value=" + node.Text);
// lblShowMessage.Text += node.Text +"
";
}
}
else
{
lblShowMessage.Text = "Sorry! You didnt select any node";
}
}
==============================================================================
my code for list box is as follow:
protected void Page_Load(object sender, EventArgs e)
{
// ListBox1.Items.Add(new ListItem("Carbon", "C"));
if (!Page.IsPostBack == true)
{
string crt = Request.QueryString["value"];
// for(
Response.Write(crt);
Response.End();
lbx_ShowSelectedGroups.Items.Add(new ListItem("Groups IN["+crt+"]"));
}
}
Please sort out this issue.
Thanks,
Junior