|
khuzwayom wrote: What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
Please put the code for this section.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi
Thanx for the reply. Here is my code
_kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
I suppose after finishing executing it should keep the Item selected displayed...
MP
|
|
|
|
|
khuzwayom wrote: _kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
What ever you have to done in the else put.
else
{
}
But still i am not able to understand where did you written the code means in which event you are loading the data and checking the value.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi Abhijit
Thanx for the assitance.
I populate the Dropwdown in page_load
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
else
{
lblMessage.Text = "The Source does not have a value"
}
If the execution got inside the if statement, it works fine, it does the calculation and keep the selected item displayed on the dropdown
but if it went ti the ELSe block, it displays the message but the dropdown displays the fisrt item which i sin index 0.
MP
|
|
|
|
|
Problem looks in Page_Load
Did you checked the ISPostBack while Loading Data on dropdown list.
if(!Page.IsPostBack)
{
}
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Yes, I did.
I think the problem is somewhere else not postback, because if th eproblem was postback it should behave the same way even when an item something in its Value property, but it only misbahes when the item has null/nothing in its Value property.
it's C#
if (!IsPostBack)
{
BindDepots();
}
MP
|
|
|
|
|
Ya got it. . Problem is with If checking
Try this
string _value = drpDepot.SelectedValue.ToString().Trim();
if (!string.IsNullOrEmpty(_value))
{
}
else
{
}
Enjoy
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi guys
Before You read this I just wanted to inform you I am using Visual Studio 2003, VB.Net as the codebehind, and running asp.net 1.1
I am currently developing an asp.net webpage where a user can input data, and then it will save that data to a Microsoft SQL Server database. The table in this database that I am saving has an ID field which I use as the primary key. The next bit of information is when the data has been inputted, and submitted it will send an email to a person which would need to view the data. This email that I want to send is a link to the data which was inputted by the user. I was wondering if it is possible to send a link to someone with the ID field of the inputted data in the URL of the link, and then have that person be able to open the link and retrieve data from the database.
Example
www.MyHours.com\timesheet\ will load up a blank timesheet for the user(Lets say his name is John) to fill out. John fills out the data, and that row in the database which has an ID of 1235, Next an email is sent out to the person(lets call this person Mary) , and she needs to view the timesheet. The URL that is sent to here www.MyHours.com\timesheet\id=1235, Then Todd fills out the data, and a new row in the database is created with an ID of 1236, and another link is sent to Mary With the url www.MyHours.com\timesheet\id=1236 which she can then click on, and view the data Todd had inputted.
If anyone knows how to do this or can just point me in the write direction on how to do this it would be greatly appreciated.
|
|
|
|
|
you can reuse the blank timesheet page to reload user data when they pass you an id. Instead of showing a blank page, query your database and load the data in the page.
Request.QueryString[^]
Ragonastick wrote: www.MyHours.com\timesheet\id=1235,
this needs to be www.myhours.com\timesheet?id=1235
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
I think what you want to do is send in your email something like this:
http://myserver/myapp/MyPage.aspx?ID=68
Then in your page_load event, you could use the following to get the ID.
myParam = Request.QueryString("ID")
In the above example, it would return 68, which you could then use to perform a database lookup.
|
|
|
|
|
|
Hello Friends,
I want to have radiobutton in GridView. But only one RadioButton must be selected and also as i select a radiobutton then that row's id should be displayed
|
|
|
|
|
Use Gridview Template Field .
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
HI,
Use Templatecolumns for placing radio buttons in gridview and after that by using javascript or server side code you can hide/visble the rows ...
|
|
|
|
|
use the following code into <column> </column> tag of your gridview
<asp:TemplateField HeaderText = "Check">
<ItemTemplate>
<input id="Radio1" type="radio" name="ss" onclick="sel(this)" />
</ItemTemplate>
</asp:TemplateField>
sel() is a js function you can use code of selecting current row
<script language="javascript" type="text/javascript">
function sel(srcElement)
{
alert('Ok');
var cb = event.srcElement;
var curElement = cb;
while (curElement && !(curElement.tagName == "TR")) {
curElement = curElement.parentElement;
}
if (!(curElement == cb) && (cb.name != "cbxSelectAll")) {
if (cb.checked) {
curElement.style.backgroundColor = "gold";
rowsSelected = rowsSelected + 1;
}
else {
curElement.style.backgroundColor = "white";
rowsSelected = rowsSelected - 1;
}
}
}
</script>
|
|
|
|
|
I am filling tree view using dataset, The problem is when i click on expand or colapse control it is not working and in browser it troughs as java error has "contentplaceholder1 treeview1 data is undefined" and some stuff...Can any1 help me thanks in advance
|
|
|
|
|
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()
|
|
|
|