|
Hi,
One way to do this by making all the columns in the grid as template columns.
then in the RowDataBound event using FindControl() method, set the value for Total label.
<br />
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )<br />
{<br />
decimal Price = Convert.ToDecimal ( ((Label)e.Item.FindControl("PriceLabel")).Text );<br />
decimal Quantity = Convert.ToDecimal ( ((Label)e.Item.FindControl("QuantityLabel")).Text );<br />
Label TotalLabel = ((Label)e.Item.FindControl("TotalLabel"));<br />
TotalLabel.Text = Convert.ToString ( Price * Quantity);<br />
}<br />
<br />
Where did error begin?
-- Naison Garvasis Pekkattil
|
|
|
|
|
Could you help me with a VB example? The "Price" column is a money type in the database and the "Quantity" column is an int type in the database. Here is the code.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
Dim TotalLabel As String
Dim Quantity As String
Dim Price As String
If e.Row.RowType = ListItemType.Item Or e.Row.RowType = ListItemType.AlternatingItem Then
End If
Decimal Price = Convert.ToDecimal ( ((Items)e.Item.FindControl("PriceLabel")).Text );
Decimal Quantity = Convert.ToDecimal ( ((Items)e.Item.FindControl("Quantity")).Text );
Decimal TotalLabel = ((Items)e.Item.FindControl("TotalLabel"));
TotalLabel = Convert.ToString(Price * Quantity)
End Sub
Thank you
|
|
|
|
|
Hi again...
I just wanna adjust location of a control like textbox whatever located on asp.net page and i wanna make it by using c# code at code-behind...
thanks in advance...
I am not a perfect programmer,but i have perfect's programmers' habits.
|
|
|
|
|
I suggest you buy a book on ASP.NET and read it. A book on HTML is an even better idea. Your server side controls, build HTML, that's how they work. You can use css to give a control an absolute position, but I would always avoid that, the flow model of HTML works well for browsers that can be resized or on different size screens.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi..
I don't know if you've ever used Gmail Upload type but I just wanna use that type upload. Ok let me tell you what i want There must be a button and when users want to add more than one file at the same time then they can just click on that button to add a new fileupload control without no page refresh and when clicking on Upload button all browsed and selected file is gonne go how can I do that ? how kind javascript code i have to use and the other processes.
Thanks in advance...
I am not a perfect programmer,but i have perfect's programmers' habits.
|
|
|
|
|
There are numerous commercial controls that do this, or you can use javascript to write your own.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Actually yeah I knew I should write my own codes but the problem is how i can do that ? Do you know any article or source code for that. It'd be so appreciated...
thanks.
I am not a perfect programmer,but i have perfect's programmers' habits.
|
|
|
|
|
The beauty of web programming is that any site that does what you want on the client side, sends you the code. The issue, from memory, is getting the controls on the server side so you can access the file data posted. I think I ended up adding a finite number of controls and show/hiding them with javascript, instead of just dynamically adding them with script.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have a major application with a few sub-applications.
One of my subfolder contains some utilities objects; that subdirectory is also inside my sub application.After conversion to 2.0 my main utility object(from the main app.) is ignoring the properties and methods that I have newly created so is the sub utility object...
Is legal to have the same folder in the main and the sub apps.?
|
|
|
|
|
Just a quick question, is the ASP.NET textbox control only capable of displaying pure text?
Is there anyway to embed a HTML link inside the textbox? Thanks!
If not, is there anything else I can use? Thanks!!!
|
|
|
|
|
Infernojericho wrote: Just a quick question, is the ASP.NET textbox control only capable of displaying pure text?
Yes. The TextBox control renders to a HTML INPUT tag which can only display unformatted text.
Infernojericho wrote: Is there anyway to embed a HTML link inside the textbox?
You could create a 'fake' textbox using a DIV tag with the contenteditable=true attribute. Not something I've really tried to do myself, but search Google and you should find some more information.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks for the reply.
Do you know if there are any 3rd party, and free (hopefully) textbox controls that support Hyperlinks?
Thanks!
|
|
|
|
|
FreeTextBox[^] is a free WYSIWYG textbox control for ASP.NET. It does a lot more than just hyperlinks, but I doubt you're going to find a control that just does hyperlinks. You'd have to write one yourself using the DIV approach I mentioned earlier.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Dear All,
I am using asp.net 1.1 and crystal report 11.
when I want to use the report in my project..I must open the report in VS
Then I should verfiy report for login(user name ,password,database..)
by right click on report then database-set location
I want parameter login,database of report to be passed at runtime.???
also I have done this for
rpt.SetDatabaseLogon(userName,password,server,databse,true);
verfiy
but I must done the prevouse ,,,
Yes. CreatiVity withOuT limiTs
modified on Wednesday, April 9, 2008 4:03 PM
|
|
|
|
|
Imports System.Data
Imports System.Io
Imports System.Data.OleDb
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
Imports CrystalDecisions.Web
Partial Class Test_rpt
Inherits System.Web.UI.Page
Dim cn As New ConnectionInfo
Dim con As New OleDbConnection
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\Website1\App_Data\Database_Name.mdb;Persist Security Info=True"
Call showreport()
End Sub
Sub showreport()
With cn
.DatabaseName ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\Website1\App_Data\Database_Name.mdb;Persist Security Info=True"
or
.DatabaseName ="Database_Name.mdb"
End With
Dim rpt As New ReportDocument
rpt.Load(Server.MapPath("report_name.rpt"))
Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo()
Dim ParamField As New ParameterField
Dim ParamField_Value As New ParameterDiscreteValue
ParamField.Name = "prj"
ParamField_Value.Value = Session("prjnm")
ParamField.CurrentValues.Add(ParamField_Value)
rpt.ParameterFields("prj").CurrentValues.Add(ParamField_Value)
ParamFields.Add(ParamField)
ParamField = New ParameterField
ParamField_Value = New ParameterDiscreteValue
ParamField.Name = "dt"
ParamField_Value.Value = Session("dt")
ParamField.CurrentValues.Add(ParamField_Value)
rpt.ParameterFields("dt").CurrentValues.Add(ParamField_Value)
ParamFields.Add(ParamField)
ParamField = New ParameterField
ParamField_Value = New ParameterDiscreteValue
ParamField.Name = "sno"
ParamField_Value.Value = Session("maxsrno")
ParamField.CurrentValues.Add(ParamField_Value)
rpt.ParameterFields("sno").CurrentValues.Add(ParamField_Value)
ParamFields.Add(ParamField)
Me.CrystalReportViewer1.ParameterFieldInfo = ParamFields
Me.CrystalReportViewer1.HasRefreshButton = False
Me.CrystalReportViewer1.HasPageNavigationButtons = False
Me.CrystalReportViewer1.HasGotoPageButton = False
Me.CrystalReportViewer1.HasToggleGroupTreeButton = False
For Each cnInfo As TableLogOnInfo In Me.CrystalReportViewer1.LogOnInfo
cnInfo.ConnectionInfo = cn
Next
Dim ms As System.IO.MemoryStream
ms = CType(rpt.ExportToStream(ExportFormatType.PortableDocFormat), System.IO.MemoryStream)
rpt.Close()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "Application/pdf"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & Session("inno1") & ".PDF")
Response.Buffer = True
Response.BinaryWrite(ms.ToArray())
Response.End()
End Sub
End Class
|
|
|
|
|
Hi, thanks for looking
Im having a weird behavior and i dont know whats going on
I have the following code:
Dim panel As New Panel
Dim lbl As New Label
lbl.ID = "Label1"
lbl.Text = "Text"
panel.Controls.Add(lbl)
Dim lbl2 As Label = CType(panel.FindControl("Label1"), Label)
lbl2 is supposed to have lbl but it has Nothing
On the immediate window i get the following info:
?panel.Controls.Count
1
?panel.Controls(0)
{System.Web.UI.WebControls.Label}
System.Web.UI.WebControls.Label: {Text = "Text"}
AppRelativeTemplateSourceDirectory: "~/Test/"
BindingContainer: Nothing
ClientID: "Label1"
Controls: {System.Web.UI.ControlCollection}
EnableTheming: True
EnableViewState: True
ID: "Label1"
NamingContainer: Nothing
Page: Nothing
Parent: {System.Web.UI.WebControls.Panel}
Site: Nothing
SkinID: ""
TemplateControl: Nothing
TemplateSourceDirectory: "/V01/Test"
UniqueID: "Label1"
Visible: True
?panel.FindControl("Label1")
Nothing
How can i get the lbl control??
I cant just use index because i might have many controls inside the panel, i wont always know the order of the controls
Thanks in advance
Alexei Rodriguez
|
|
|
|
|
Did you add the panel to the form control collection?
form1.controls.add(panel);
MrPlankton
|
|
|
|
|
Thanks for the reply
Adding the panel to the form solves the problem
I hadnt tought about it
If im inside a class, how can i add those panels to the form?
(In httpcontext.current. i dont see anything like page) I can only think of sending page as a parameter, but is that my only option?
If you know any other, please let me know
Im using this functions where i insert and read controls from panels and the normal flow is insert them, and show them on the client, then read the options set on the client and save those to db
In this case, where this is not working is now that im doing this directly (Not sending it to the client), im just inserting the controls, setting values im reading from DB and then reading them (Here is where im getting hte error)(This might seem dumb, but in the function where i read the values, som calculations are done and i would like to reuse thos function the way they are)
Alexei Rodriguez
|
|
|
|
|
Pass the controls collection.
MrPlankton
|
|
|
|
|
I'm trying to use headers property of httpwebrequest to send a cookie to a server. For diong so, ii'm using add method of httpwebrequest.headers.
I can add any header included cookies. But, the problem is the cookie is not recieved by the server.
How i know that is simple. I wrote one page on server that prints request headers and cooikes. when i use my code on this page the cookie is not there (as i said before any other headers will be shown in this page az request headers).
Please somebody help.
|
|
|
|
|
|
I think u misunderstood me. I want to send cookies from client to server. cookiecontainer is an object for response to put cookies in it. without it httpwebresponse can't send cookies back to client.
|
|
|
|
|
raha2002 wrote: I think u misunderstood me. I want to send cookies from client to server. cookiecontainer is an object for response to put cookies in it. without it httpwebresponse can't send cookies back to client.
How do you know that? Did you try it? I did and it works just fine.
HttpWebRequest req = WebRequest.Create("http://localhost/Research/RequestViewer.aspx") as HttpWebRequest;
Cookie cook = new Cookie();
cook.Name = "TestCookie";
cook.Value = "CookieValue";
cook.Domain = "localhost";
req.CookieContainer = new CookieContainer();
req.CookieContainer.Add(cook);
WebResponse res = req.GetResponse();
Stream s = res.GetResponseStream();
StreamReader sr = new StreamReader(s);
while (!sr.EndOfStream)
Console.WriteLine(sr.ReadLine());
led mike
|
|
|
|
|
I have 2 dropdownlists on a formview. The list of the second one (ddl_2) is depend on the selected value of the first one (ddl_1). I use a client callback function (GetDDL2List) on event OnChange to retrieve the list for the second one. After I selected for a value from the first one list of the second come out correctly. After I make a selection from the second one and submit (post back) the form, however, the selection of the second one is lost.
<asp:DropDownList ID="ddl_1" Runat="server" DataSourceID="ods_1" DataValueField="cde_item" DataTextField="txt_item" OnDataBound="ddl_1_DataBound" onchange="GetDDL2List(this.value, 'ddl'); " />
<asp:ObjectDataSource ID="ods_1" Runat="server" TypeName="Proj1.Test" SelectMethod="GetList1"
</asp:ObjectDataSource>
<asp:DropDownList ID="ddl_2" Runat="server" DataSourceID="ods_2" DataValueField="cde_tem" DataTextField="txt_item" OnDataBound="ddl_2_DataBound" />
<asp:ObjectDataSource ID="ods_2" Runat="server" TypeName="Proj1.Test" SelectMethod="GetList2"
<SelectParameters>
<asp:ControlParameter Name="sGroup" ControlID="ddl_1" DefaultValue="-1" Type="string" />
</SelectParameters>
</asp:ObjectDataSource>
|
|
|
|
|
Verify that when you bind your DropDownLists that you are only doing it if !Page.IsPostBack
|
|
|
|