senprog
asked on
Get the Selected Item Text from the treeview control
I populate the data to a treeview where i need to get the selected text. How to do it..
Below is the code in page_load event.
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
strSql="Select contentid,headline,menucap tion,menul evel,paren tmenuorder ,";
strSql+="release,contentno from tblcontent";
// Establish Connection
SetConnection();
objContentDa = new OdbcDataAdapter(strSql,Obj Con);
objDs = new DataSet();
objContentDa.Fill(objDs,"C ontent");
//Clean up.
objDs.Dispose();
objContentDa.Dispose();
ObjCon.Close();
//Populate the TreeView from the DataSet.
foreach (DataRow rowContent in objDs.Tables["Content"].Ro ws)
{
nodeContent = new TreeNode();
nodeContent.Text = rowContent["menucaption"]. ToString() ;
TreeView1.Nodes.Add(nodeCo ntent);
}
}
When I press a button (server control) i need to get the text on which the user selected the node.
Thanks in advance
Below is the code in page_load event.
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
strSql="Select contentid,headline,menucap
strSql+="release,contentno
// Establish Connection
SetConnection();
objContentDa = new OdbcDataAdapter(strSql,Obj
objDs = new DataSet();
objContentDa.Fill(objDs,"C
//Clean up.
objDs.Dispose();
objContentDa.Dispose();
ObjCon.Close();
//Populate the TreeView from the DataSet.
foreach (DataRow rowContent in objDs.Tables["Content"].Ro
{
nodeContent = new TreeNode();
nodeContent.Text = rowContent["menucaption"].
TreeView1.Nodes.Add(nodeCo
}
}
When I press a button (server control) i need to get the text on which the user selected the node.
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.