Click here to Skip to main content
15,891,204 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerUse a query parameter in the URL Pin
David Mujica18-Mar-09 4:16
David Mujica18-Mar-09 4:16 
GeneralRe: Use a query parameter in the URL Pin
Ragonastick23-Mar-09 9:42
Ragonastick23-Mar-09 9:42 
QuestionRadioButton in GridView Pin
.NET- India 18-Mar-09 2:14
.NET- India 18-Mar-09 2:14 
AnswerRe: RadioButton in GridView Pin
Abhijit Jana18-Mar-09 2:47
professionalAbhijit Jana18-Mar-09 2:47 
AnswerRe: RadioButton in GridView Pin
kumar_k50818-Mar-09 2:50
kumar_k50818-Mar-09 2:50 
AnswerRe: RadioButton in GridView Pin
Ravindra Bisen18-Mar-09 21:37
Ravindra Bisen18-Mar-09 21:37 
QuestionTree View Pin
sunil.n.cs18-Mar-09 1:08
sunil.n.cs18-Mar-09 1:08 
GeneralRe: Tree View Pin
hisrikanthreddy18-Mar-09 1:28
hisrikanthreddy18-Mar-09 1:28 
i am giving one example which i did.....
i hope it will help's you.....


]]>





<title>Untitled Page




 
<asp:treeview id="TreeView1" runat="server" onselectednodechanged="TreeView1_SelectedNodeChanged" style="z-index: 100; left: 476px;<br mode=" hold=" /> position: absolute; top: 342px" xmlns:asp="#unknown">

<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged" xmlns:asp="#unknown">
Style="z-index: 101; left: 555px; position: absolute; top: 266px">












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.Data.SqlClient;
public partial class etc : System.Web.UI.Page
{

SqlConnection cn=new SqlConnection("User ID=sa; password=sa; Initial Catalog=sri; Data Source=TNLMSSRV");

string[] rolesArray;

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
rolesArray = Roles.GetAllRoles();
DropDownList1.DataSource = rolesArray;
DropDownList1.DataBind();
}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
PopulateRootLevel();
}

private void PopulateRootLevel()
{
SqlConnection objConn = new SqlConnection("Data Source=TNLMSSRV;Initial Catalog=sri;User ID=sa;Password=sa");
//SqlCommand objCommand=new SqlCommand("select a.groupid,d.featureid,a.name,b.featurename,b.featurepath from groups a,features b,aspnet_roles c,rolesfeatures d where a.groupid=b.groupid and b.featureid = d.featureid and c.roleid = d.roleid and c.roleid = (select roleid from aspnet_usersInRoles where userid=(select userid from aspnet_users where username='sri'))order by a.sorder,3", objConn);
SqlCommand objCommand = new SqlCommand("select a.groupid, d.featureid, a.name, b.featurename, b.featurepath from groups a,features b,aspnet_roles c,rolesfeatures d where a.groupid=b.groupid and b.featureid = d.featureid and c.roleid = d.roleid and c.roleid = (select roleid from aspnet_roles where rolename='" + DropDownList1.SelectedItem + "') order by a.sorder,3", objConn);
SqlDataAdapter da = new SqlDataAdapter(objCommand);
DataTable dt = new DataTable();
da.Fill(dt);
PopulateNodes(dt, TreeView1.Nodes);
}

private void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
{
TreeView1.Nodes.Clear();
foreach (DataRow dr in dt.Rows)
{
Boolean opt=false;
foreach (TreeNode tn in TreeView1.Nodes)
{
if(tn.Text == dr["name"].ToString())
{
opt=true;
TreeNode tnn = new TreeNode();
tnn.Text = dr["featurename"].ToString();
tn.ChildNodes.Add(tnn);
break;
}
}

if (opt==false )
{
TreeNode tn = new TreeNode();
tn.Text = dr["name"].ToString();
tn.Value = dr["groupid"].ToString();
nodes.Add(tn);
TreeNode tnn = new TreeNode();
tnn.Text = dr["featurename"].ToString();
tn.ChildNodes.Add(tnn);
}
}
}

protected void TreeView1_TreeNodePopulate(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
{
PopulateSubLevel(int.Parse(e.Node.Value), e.Node);
}

private void PopulateSubLevel(int groupid, TreeNode parentNode)
{
SqlConnection objConn = new SqlConnection("Data Source=TNLMSSRV;Initial Catalog=sri;User ID=sa;Password=sa");
SqlCommand objCommand = new SqlCommand("select featurename from features where groupid=@groupid", objConn);
objCommand.Parameters.Add("@groupid", SqlDbType.Int).Value = groupid;
SqlDataAdapter da = new SqlDataAdapter(objCommand);
DataTable dt = new DataTable();
da.Fill(dt);
PopulateNodes(dt, parentNode.ChildNodes);
TreeView1.CollapseAll();
}





//private void ExpandNodes(String valuepath)
//{

//}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
if (TreeView1.SelectedNode.Parent == null)
{

}
else
{
SqlCommand cmd = new SqlCommand("select featurepath from Features where Featurename='" + TreeView1.SelectedNode.Text + "'", cn);
if (cn.State == ConnectionState.Closed)
cn.Open();
String pp = cmd.ExecuteScalar().ToString();
cn.Close();
Response.Redirect(pp);

}

//ExpandNodes(TreeView1.SelectedNode.ValuePath);
}


}

Srikanth Reddy

QuestionAsp.Net MVC Redirect to external link Pin
Razvan Dimescu18-Mar-09 0:22
Razvan Dimescu18-Mar-09 0:22 
AnswerRe: Asp.Net MVC Redirect to external link Pin
N a v a n e e t h18-Mar-09 1:02
N a v a n e e t h18-Mar-09 1:02 
QuestionFileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
ven32117-Mar-09 23:44
ven32117-Mar-09 23:44 
AnswerRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Christian Graus18-Mar-09 0:01
protectorChristian Graus18-Mar-09 0:01 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
ven32118-Mar-09 0:42
ven32118-Mar-09 0:42 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Subin Alex18-Mar-09 0:55
Subin Alex18-Mar-09 0:55 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
ven32118-Mar-09 1:28
ven32118-Mar-09 1:28 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Subin Alex18-Mar-09 2:19
Subin Alex18-Mar-09 2:19 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
ven32118-Mar-09 2:41
ven32118-Mar-09 2:41 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Christian Graus18-Mar-09 10:25
protectorChristian Graus18-Mar-09 10:25 
RantRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Paddy Boyd18-Mar-09 3:38
Paddy Boyd18-Mar-09 3:38 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Christian Graus18-Mar-09 10:25
protectorChristian Graus18-Mar-09 10:25 
GeneralRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Christian Graus18-Mar-09 10:24
protectorChristian Graus18-Mar-09 10:24 
AnswerRe: FileUpload1.Postedfile.FileName not working in firefox/safari.....in asp.net Pin
Subin Alex19-Mar-09 2:14
Subin Alex19-Mar-09 2:14 
QuestionDirectly insertion from grid view Pin
Abhishek Rana17-Mar-09 23:37
Abhishek Rana17-Mar-09 23:37 
AnswerRe: Directly insertion from grid view Pin
Abhijit Jana18-Mar-09 0:01
professionalAbhijit Jana18-Mar-09 0:01 
QuestionHow to design in div tag Pin
ais0717-Mar-09 23:34
ais0717-Mar-09 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.