|
hi Castle rider,
thanks for your reply.can you give code example of your answer. i am giving here more details of my question. i need to display running total of all the textboxes in GridView in the lable at bottom of gridview. this should include textboxes on other pages of gridview too.
<asp:GridView ID="gv_Transaction" runat="server" AutoGenerateColumns="False" Width="80%" HorizontalAlign="Center" CellPadding="4" GridLines="None" ShowFooter="True">
<FooterStyle HorizontalAlign="Center"/>
<asp:BoundField HeaderText="Employee Name" DataField="Ename" SortExpression="Ename">
<ItemStyle Width="100px" />
</asp:BoundField>
<asp:BoundField HeaderText="SSN" DataField="ssn" SortExpression="ssn" >
<ItemStyle Width="80px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Amount" >
<ItemTemplate>
$ <asp:TextBox ID="txt_dollar" runat="server" Width="60px" MaxLength="12" style=" text-align:right;" CausesValidation="true" onChange="Add()" /b>gt;</asp:TextBox>
<asp:RegularExpressionValidator ID="reg_dollar" runat="server" ValidationExpression="^\d*\.?(\d{2})$" ErrorMessage="<b>Incorrect Format</b>" SetFocusOnError="true" Display="Dynamic" ControlToValidate="txt_dollar">
<asp:ImageButton ID="img_amt" runat="server" ImageUrl="~/Images/error.gif" AlternateText="Incorrect Format" />
</asp:RegularExpressionValidator>
</ItemTemplate>
<ItemStyle Width="80px" />
</asp:TemplateField>
<asp:BoundField HeaderText="Status" DataField="status" SortExpression="status">
<ItemStyle Width="60px" />
</asp:BoundField>
</Columns>
</asp:GridView>
And at bottom i have a label showing total amount
<td style="width:10%; text-align:right; color:#2572a7;">Total Dollar Amount:</td>
<td style="width:15%;color:#2572a7; "><asp:Label ID="lbl_TotAmount" runat="server"></asp:Label></td>
I am calling this Javascript function on Onchange Event of Textbox in the grid.that does the addition is
var obj = window.event.srcElement;
var tBox;
var sum = 0;
if(obj.tagName == "INPUT" && obj.type == "text" )
{
tBox = document.getElementsByTagName("INPUT");
for(i = 0; i< (tBox.length - 2) ; i++)
{
if(tBox[i].type == "text")
{
if ((parseFloat(tBox[i].value)) && tBox[i].id !="ctl00_ContentPlaceHolder1_payDate_txt_Date" )
{
sum += Number(tBox[i].value);
}
}
}
}
sum=sum.toFixed(2).toString(10)
document.getElementById("ctl00_ContentPlaceHolder1_lbl_TotAmount").innerText = sum;
Once again Thanks for your reply...
The Beginer..
|
|
|
|
|
I really dont know if this is the best place to ask this question but here it goes...
Background Information:
I am creating template C# 2008 web sites that contain different modules. I may have web sites A, B, C, D, etc that each contain different modules. A module could be a couple different things. It could be a GUI change such as a side panel on the main web page like in code project on the left where it says chapters, Announcements, etc. Another example could be new web pages like a shopping cart with paypal or google checkout. Another would be web site polling such as the one on www.PollPro.com while would be code changes and additional web pages. A module could mean C# server side code changes to files, HTML code changes, and or including of files that dont exist, and or changes to the SQL Server the web site is using.
The Question:
What is the best way to start accomplish this in a very maintainable way?
Possible Answers:
1. Create a base web site that contains no modules at all. Then within the code place sections that could be between commented sections like // GOOGLECHECKOUTMODULE_BEGIN and // GOOGLECHECKOUTMODULE_END . Then build an application that will remove all the sections and a specified list of files if the module is not selected. The problem with this is that other modules could be using the same files. Another problem is that this project would become a maintaince nightmare with all the different commented sections.
2. Create a base web site that contains no modules at all. Then copy that project and add only one module. Then when a module is selected the two projects need to be merged together. This would include merging files and adding files that dont exist. Merging coded files may be a little work but is possible. If different modules contain the same file name that needs to be added then which one is used?
Any other options?
|
|
|
|
|
Currently i m working on a table which have n level structure
(it has Process name and Parentprocess Name in it)
So his way i defined n level of it
now thrugh cursor i want to fetch and i only do have 0'th level
Process Name
thrugh cursor i only do get one level Sub process
(i need sthin like while loop )
how to do it
|
|
|
|
|
What has this to do with ASP.NET? It sounds like a sql problem. If you have SQL Sevrer 2005/2008 google for CTE (Common Table Expression), it does exactly what you are looking for.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
You can do this in asp.net instead of in sql server
Load all the records and implement a function which you will call recursively to populate your data in any desired way
Alexei Rodriguez
|
|
|
|
|
HY,
i wanted to show de contents of a csv(comma separated file) file on a gridview(asp.net using c#)..can any one plz help me out
|
|
|
|
|
Read the file, load it into a collection or data table and use that as the data source for the grid view.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
You can use TextFieldParser class to do your task.
Something like this,
TextFieldParser fp = new TextFieldParser("mycsv.txt");
fp.Delimiters = {"\t"};
while (!fp.EndOfData)
{
}
|
|
|
|
|
In my .net projects I always tend to have an n-tier architecture.
I access the business layer from the presentation layer using references and code.
It seems the object data source does a similar task.
Am I right?
I have seen the object data source in action but it seems to me it does the same thing as what I am doing to access the business layer.
Am I right?
What do you think?
Thanks
|
|
|
|
|
Hello,
I am developing Intranet web site. run on IIS. I have a txt file save on server inculde 'n' no of lines. when this txt file upload on server and save on sql server then no probleam. Client access my web site and client Computer have a txt file. when client upload txt file. then show message file not found.
|
|
|
|
|
So are you saying a client is trying to upload a file to your server or are they trying to download it from your server?
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Rinki Mukheraji wrote: I have a txt file save on server inculde 'n' no of lines.
Does this means, you the have the text file in the Server first?
Rinki Mukheraji wrote: when client upload txt file. then show message file not found.
Seems like your using FileUpload Control's FileName property to upload the client file. Use PostedFile property.
|
|
|
|
|
Hi, I'm trying to write a program that can access different databases(mainly Sql Server and Oracle).
I've thought about using the Database Application Access Block which seems to be the best way but can't find a decent example of how to use it with oracle. If anyone has any other ideas on how to accomplish this please let me know.
Thanks
|
|
|
|
|
I would like to add a control to a panel during runtime;
this is what im doing
TextBox str = new TextBox();
str.id = Test;
str.Width = Unit.Pixel(100);
str.Height = Unit.Pixel(100);
this.Panel3.Controls.Add(str);
to my suprise this conrol is not being added;
does anyone know whats wrong with this code;
|
|
|
|
|
What event are you adding the control in? Page_Load
Be careful where the controls are you have to take in to account postback
A good article to read would be on Page Life Cycle
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Hi, Thank you very much, im page_load event.
Thank i will read the article you sent me.
|
|
|
|
|
I tried to export datagrid data to the excel. I got problem while exporting data to excel while working in IIS.It is showing COM file is missing.Please help me out
Haripriya
|
|
|
|
|
Hi,
Can you explain how you are exporting data to excel....It will help to get ur problem solve quickly..
If u want you can use the below code for exporting the data in excel.....
private void btnExportToExcel_Click(object sender, System.EventArgs e)
{
dataGrid1.DataSource=TT_Reports.getDefaultersList(DateTime.Parse(TxtFromDate.Text),DateTime.Parse(TxtToDate.Text ),ddnTeamList.SelectedValue.ToString());
dataGrid1.DataBind();
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
Response.AddHeader("content-disposition", "attachment;filename=DefaultersList_"+DateTime.Today.ToShortDateString()+".xls");
this.ClearControls(dataGrid1);
dataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
private void ClearControls(Control control)
{
for (int i=control.Controls.Count -1; i>=0; i--)
{
ClearControls(control.Controls[i]);
}
if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
LiteralControl literal = new LiteralControl();
control.Parent.Controls.Add(literal);
try
{
literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control,null);
}
catch
{
}
control.Parent.Controls.Remove(control);
}
else
if (control.GetType().GetProperty("Text") != null)
{
LiteralControl literal = new LiteralControl();
control.Parent.Controls.Add(literal);
literal.Text = (string)control.GetType().GetProperty("Text").GetValue(control,null);
control.Parent.Controls.Remove(control);
}
}
return;
}
|
|
|
|
|
Ya i used this code which u have pasted but it is not for multisheets of excel.Thats y i tried like this
Dim obj_xl As New Excel.Application()
Try
obj_xl = GetObject(, "Excel.Application")
Catch ex As Exception
obj_xl = GetObject("", "Excel.Application")
End Try
obj_xl.Application.Visible = True
obj_xl.Workbooks.Add()
obj_xl.Sheets("Sheet1").Select()
With obj_xl
For i = 0 To dt.Rows.Count - 1
For j = 0 To dt.Columns.Count - 1
If IsDBNull(dt.Rows(i).Item(j)) Then
.ActiveCell(i + 4, j + 1) = String.Empty
Else
.ActiveCell(i + 4, j + 1) = dt.Rows(i).Item(j) End If
Next
Next
obj_xl.Dialogs(Excel.XlBuiltInDialog.xlDialogSaveAs).Show()
End With
This was the method i using to export values from data table.
I used some COM components for excel
This worked fine in my system.When i try to run in IIS its showing error as COM file missing
|
|
|
|
|
Use This Code:
protected void bttbexcel_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter stringWrite);
GridView1.RenderControl(htmlWrite);
this.EnableViewState = false;
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
GridView1.Attributes["runat"] = "server";
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
|
|
|
|
|
Sneha Bisht wrote: Use This Code:
protected void bttbexcel_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter stringWrite);
GridView1.RenderControl(htmlWrite);
this.EnableViewState = false;
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
GridView1.Attributes["runat"] = "server";
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
The Excel is not true excel.
|
|
|
|
|
I am adding controls to a placeholder on the fly.
I could have any number of controls in there but its usually about 5.
I am adding a label and a textbox to the placeholder.
Now when I loop the placeholder I have the following code:
The textbox value works fine it finds the correct value, but I cant find the label value, why is this?
Any help would be great.
thanks
PlaceHolder placeHolder1 = (PlaceHolder)FindControl("PlaceHolder2");
foreach (Control c in PlaceHolder2.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
Label lb2 = (Label)c;
TextBox tb2 = (TextBox)c;
SqlCommand cmdinsertliftunion = new SqlCommand("INSERT INTO table(field1, field2) VALUES ('" + lb2.Text + "', '" + tb2.Text + "')", con);
cmdinsert.ExecuteNonQuery();
}
}
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
modified on Wednesday, October 8, 2008 5:39 AM
|
|
|
|
|
The code
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
spessifies that it only goes into the statment if it is an TextBox
try
Label lb2;
TextBox tb2;
foreach (Control c in PlaceHolder2.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
TextBox tb2 = (TextBox)c;
}
else if(c.GetType().ToString().Equals("System.Web.UI.WebControls.Label"))
{
lb2 = (Label)c;
}
}
}
SqlCommand cmdinsertliftunion = new SqlCommand("INSERT INTO table(field1, field2) VALUES ('" + lb2.Text + "', '" + tb2.Text + "')", con); cmdinsert.ExecuteNonQuery();
|
|
|
|
|
But I need the sql statement to be in the loop, will this still work?
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Are you adding multiple textboxes and labels to the placeholder?
In that case you need to know witch of the labels og textboxes pair you wan't to insert.
|
|
|
|