|
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
|
|
|
|
|
How can I send as a response a redirection to an external link?
With asp.net I was using Response.Redirect("externalLink")
|
|
|
|
|
Razvan Dimescu wrote: I was using Response.Redirect("externalLink")
That should work. What is the problem you are facing?
|
|
|
|
|
Hi,
i want fullpath when i select a file it works in IE but not in safari..firefox...etc..
FileUpload1.Postedfile.FileName returns the filename along with its full path which have to be uploaded in IE, but it returns only filename when we run application in Firefox.
if any body knows any replacement function then plz let me know.
Thank you
|
|
|
|
|
You've been asking this for days. I still don't see how knowing what path a file came from on the clients computer, is of use to you. If it is, write an activeX that will help you get to that info.
If you knew anything about ASP.NET, you'd know that it generates HTML, and no matter what the platform, you've obviously hit a limitation of the control in FIrefox ( some would say, a security feature ). I'd be amazed if there's a way around it without using a java applet ( ActiveX won't run in FF, of course )
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Sir thank you for respond actually i new to Asp.net
i am uploading the image to server via ftp...
it is working fine when i use IE
In other browser...when load the file from specific path...that full path is not coming..
----------------------------------
string filePath = FileUpload1.PostedFile.FileName; -->comes full path in IE not in other browsers...
//Load the file
FileStream stream = File.OpenRead(filePath);-->bug is coming here
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
|
|
|
|
|
Try this
Server.mappath(FileUpload1.Postedfile.FileName)
|
|
|
|
|
hi thanx for respond...
string filePath = Server.MapPath(FileUpload1.PostedFile.FileName);
it takes path where website is there..ie..if i have website in f:\
if i have selecte image in desktop/d drive..it also takes path from f:\ drive only..but that image has in other drive...so bug will come...
pls..help me.......
thank you..........
|
|
|
|
|
Try to put this code for getting the path in the Form_Load()
|
|
|
|
|
Thanks for responce..
string filePath = Server.MapPath(FileUpload1.PostedFile.FileName);
but same problem...it is not taking selected file path...
thank u
|
|
|
|
|
The guy who answered you is more clueless than you are. Ignore him.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Well that's just plainly not going to work. The server part at the start should be a bit of a giveaway...
|
|
|
|
|
Don't answer if you don't know, please.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
qn123 wrote: Sir thank you for respond actually i new to Asp.net
Well, there's a surprise. If you're new to ASP.NET, why are you working so hard on this issue ? Surely you're not writing code that you're paid for ? You're new, so you'd be learning, in a class, or by yourself, right ? So drop the firefox thing, it plainly won't work, and you'd have to be very dishonest to be doing paid work when you're new, so whatever project you're doing for fun, just accept that Firefox doesn't do what you want it to, and move on.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Try this!
string strfile=Path.GetFileName(txtUpload.PostedFile.FileName);
string strdr=Request.PhysicalApplicationPath+"<name of="" the="" folder="">\\";
|
|
|
|
|
I have to add the data directly from the gridview .
so how should i achieve the same
|
|
|
|
|
Abhishek Rana wrote: I have to add the data directly from the gridview .
so how should i achieve the same
Did you search google before posting it over here ?
I have searched got it[^]
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi there,
Previouly I was desigining my Asp.Net Pages by taking Table.But It gives me problem when I change browser.So now I want to design my pages in div tag.I dont know how to design.Can anybody help me with some usefull link where I can get Information regarding this.
Thanks,
|
|
|
|
|
<div id="myDiv" title="myDiv" align="center" style="border:thick #000000">
Hi Try this Div
</div>
|
|
|
|
|
This[^] site have some tutorials on CSS. You have to take a book on CSS and web design for more details.
|
|
|
|
|
how to export stored procedures from local sql server 2000 to microsoft sql server,
i am sending but that is failed to copy. so plz send me the details.
somasekhar
j somasekhar
|
|
|
|
|
somasekhara777 wrote: how to export stored procedures from local sql server 2000 to microsoft sql server,
You want to mean that, you want to export SQL Server 200 SP to SQL Server 2005 or what?
somasekhara777 wrote: i am sending but that is failed to copy..
How ?
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
You can script each SP in Sql 2000 with the right mousebuttonclick on the SP name.
If you combine all scripts into 1 large script....run that script on your new database
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi to all,
I have in a datatable select method. I am unable to find what is going wrong.
Please give some guidance.
I am trying to do like this:
public void get_data()
{
try
{
pro_id = Request.QueryString["pr_id"];
quanti = Convert.ToInt32(Request.QueryString["quant"]);
if (pro_id != null)
{
SqlConnection con = new SqlConnection("Server=.; Database=eclsc; Trusted_Connection=yes");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select ICEMACHINES.product_id,ICEMACHINES.sh_desc,ICEMACHINES.price from ICEMACHINES where ICEMACHINES.product_id LIKE @product_id union select GLASSWARE.product_id,GLASSWARE.sh_desc,GLASSWARE.price from GLASSWARE where GLASSWARE.product_id LIKE @product_id ";
cmd.Parameters.Add("@product_id", SqlDbType.NVarChar, 50).Value = pro_id;
cmd.Connection.Open();
SqlDataReader rdr = cmd.ExecuteReader();
ArrayList arRole1 = new ArrayList();
while (rdr.Read())
{
desc = (rdr["sh_desc"]).ToString();
id = (rdr["product_id"]).ToString();
unitprice = Convert.ToSingle((rdr["price"]));
cost = unitprice * quanti;
}
cmd.Connection.Close();
DataRow myrow = dt.NewRow();
myrow["REF"] = id;
myrow["Description"] = desc;
myrow["QTY"] = quanti;
myrow["Price"] = unitprice;
myrow["Cost"] = cost;
int dtcount = dt.Rows.Count;
if (dtcount > 0)
{
DataRow[] arrMatchingValues = dt.Select("REF=" + id);
if (arrMatchingValues.Length > 0)
{
DataRow drUpdateMe = arrMatchingValues[0];
int drUpdateQuant = Convert.ToInt32(drUpdateMe["QTY"]);
int quan = quanti + drUpdateQuant;
drUpdateMe["QTY"] = quan;
dt.AcceptChanges();
}
}
else
{
dt.Rows.Add(myrow);
dt.AcceptChanges();
}
Session["data"] = dt;
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
int a = 1;
}
total_items = total_items + quanti;
total_Price = total_Price + cost;
Session["items"] = total_items;
Session["value"] = total_Price;
}
catch(Exception ee)
{
Lblmsg.Text = ee.Message;
}
}
The problem is in the filter expression. Actually I am trying that if a item already exists in the gridview then only the quantity should be updated.But I am unable to do this.
Please give some suggestions..
cheers,
sneha
|
|
|
|
|
hi.
in this u will get only single row.?
|
|
|
|