Search Results

Search found 1260 results on 51 pages for 'gridview'.

Page 12/51 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • FAQ: GridView Calculation with JavaScript - Editable Price Field

    - by Vincent Maverick Durano
    Recently I wrote a series of blog posts that demonstrates how to do calculation in GridView using JavaScripts. You can check the series of posts below: FAQ: GridView Calculation with JavaScript FAQ: GridView Calculation with JavaScript - Formatting and Validation FAQ: GridView Calculation with JavaScript - Displaying Quantity Total Recently a user in the forums is asking how to calculate the total quantity, sub-totals and total amout in GridView  when a user enters the price and quantity in the TextBox field. Obviously the series of post  that I wrote will not work in this case because the price field in those examples are Label (read-only) and not TextBox fields. In this post I'm going to demonstrate how to accomplish this using the same method used in my previous examples. Basically I'm just going to modify the GridView declaration and replace the Label price field with a TextBox so that users can type on it. And finally modify the CalculateTotals() javascript function. Here are the code blocks below: <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <script type="text/javascript"> function CalculateTotals() { var gv = document.getElementById("<%= GridView1.ClientID %>"); var tb = gv.getElementsByTagName("input"); var lb = gv.getElementsByTagName("span"); var sub = 0; var total = 0; var indexQ = 1; var indexP = 0; var price = 0; var qty = 0; var totalQty = 0; var tbCount = tb.length / 2; for (var i = 0; i < tbCount; i++) { if (tb[i].type == "text") { ValidateNumber(tb[i + indexQ]); sub = parseFloat(tb[i + indexP].value) * parseFloat(tb[i + indexQ].value); if (isNaN(sub)) { lb[i].innerHTML = "0.00"; sub = 0; } else { lb[i].innerHTML = FormatToMoney(sub, "$", ",", "."); ; } if (isNaN(tb[i + indexQ].value) || tb[i + indexQ].value == "") { qty = 0; } else { qty = tb[i + indexQ].value; } totalQty += parseInt(qty); total += parseFloat(sub); indexQ++; indexP++; } } lb[lb.length - 2].innerHTML = totalQty; lb[lb.length -1].innerHTML = FormatToMoney(total, "$", ",", "."); } function ValidateNumber(o) { if (o.value.length > 0) { o.value = o.value.replace(/[^\d]+/g, ''); //Allow only whole numbers } } function isThousands(position) { if (Math.floor(position / 3) * 3 == position) return true; return false; }; function FormatToMoney(theNumber, theCurrency, theThousands, theDecimal) { var theDecimalDigits = Math.round((theNumber * 100) - (Math.floor(theNumber) * 100)); theDecimalDigits = "" + (theDecimalDigits + "0").substring(0, 2); theNumber = "" + Math.floor(theNumber); var theOutput = theCurrency; for (x = 0; x < theNumber.length; x++) { theOutput += theNumber.substring(x, x + 1); if (isThousands(theNumber.length - x - 1) && (theNumber.length - x - 1 != 0)) { theOutput += theThousands; }; }; theOutput += theDecimal + theDecimalDigits; return theOutput; } </script> </head> <body> <form id="form1" runat="server"> <asp:gridview ID="GridView1" runat="server" ShowFooter="true" AutoGenerateColumns="false"> <Columns> <asp:BoundField DataField="RowNumber" HeaderText="Row Number" /> <asp:BoundField DataField="Description" HeaderText="Item Description" /> <asp:TemplateField HeaderText="Item Price"> <ItemTemplate> <asp:TextBox ID="TXTPrice" runat="server" onkeyup="CalculateTotals();"></asp:TextBox> </ItemTemplate> <FooterTemplate> <b>Total Qty:</b> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Quantity"> <ItemTemplate> <asp:TextBox ID="TXTQty" runat="server" onkeyup="CalculateTotals();"></asp:TextBox> </ItemTemplate> <FooterTemplate> <asp:Label ID="LBLQtyTotal" runat="server" Font-Bold="true" ForeColor="Blue" Text="0" ></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Total Amount:</b> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Sub-Total"> <ItemTemplate> <asp:Label ID="LBLSubTotal" runat="server" ForeColor="Green" Text="0.00"></asp:Label> </ItemTemplate> <FooterTemplate> <asp:Label ID="LBLTotal" runat="server" ForeColor="Green" Font-Bold="true" Text="0.00"></asp:Label> </FooterTemplate> </asp:TemplateField> </Columns> </asp:gridview> </form> </body> </html>   That's it! I hope someone find this post useful! Technorati Tags: ASP.NET,GridView,JavaScript

    Read the article

  • Checking All Checkboxes in a GridView Using jQuery

    In May 2006 I wrote two articles that showed how to add a column of checkboxes to a GridView and offer the ability for users to check (or uncheck) all checkboxes in the column with a single click of the mouse. The first article, Checking All CheckBoxes in a GridView, showed how to add "Check All" and "Uncheck All" buttons to the page above the GridView that, when clicked, checked or unchecked all of the checkboxes. The second article, Checking All CheckBoxes in a GridView Using Client-Side Script and a Check All CheckBox, detailed how to add a checkbox to the checkbox column in the grid's header row that would check or uncheck all checkboxes in the column.

    Read the article

  • ASP.NET 3.5 GridView Images

    You might have learned how to put hyperlinks in the GridView in Tuesday s tutorial on ASP.NET 3.5 GridView hyperlink columns. One of GridView s important features lets you display images retrieved from the database. These images are then rendered in the browser using the HTML image tag. This tutorial will show you how to take advantage of this feature which has several applications in e-commerce and online catalogs.... Transportation Design - AutoCAD Civil 3D Design Road Projects 75% Faster with Automatic Documentation Updates!

    Read the article

  • ASP.Net GridView Sorting

    - by Ali Shafai
    I have a grid view with AllowSorting set to true. I get an event onsorting when a sortable header is clicked on. the handler has a parameter "GridViewSortEventArgs e" which has a SortDirection property on it. regardless of how many times you click on the same heading, the SortDirection is always Ascending. I think I'm missing something, like a way to tell the grid "now you are sorted based on column one and in ascending order", so that next time the grid sees a click on the "column one" heading, it decides to go descending. any help appreciated. Cheers, Ali

    Read the article

  • C# how to display datetimepicker control for all rows of gridview

    - by ronny
    Hi, In my application I am creating rows and columns dynamically. I created a column of type System.DateTime. After this i want to display datetimepicker control for all rows in that column. I created a column using dataTable.Columns.Add("CreatedOn", Type.GetType("System.DateTime")); and i am adding rows as foreach(String filename ......) dataTable_FileProperty.Rows.Add(filename,//here i want to add dateTimePicker So, what is a solution for this. EDIT: Please provide some code snippet. I am new to C#.net. Thanks.

    Read the article

  • Get ID in GridView

    - by Romil
    Hi, I have One grid say Grid 1 in which there are some columns. There is one view image button, one delete image button and one column which says that color column is Red or Blue. If color column is Red the deleted button is hidden else its shown (Based on user given rights to delete a column or not). Now a user clicks a view button for Red Color Column. If this condition is satisfied, then i want that delete icon should not be present in Grid 2. Grid 2 has 2 columns. One is deleted image button and one is file name (which is uploaded via upload control). So If in Grid One "View Image Button" is clicked for "Red" Column i should be able to hide the delete button from Grid 2. I have tried by writing code in Item command but i am not able to access control of grid2. is this the correct way? Or else suggest me some correct way. Please Make sure that code is compatible with VS 2003. let me know if more inputs are needed. Thanks

    Read the article

  • ASP.NET - working with GridView Programmatically

    - by JMSA
    I am continuing from this post. After much Googling, I have come up with this code to edit cells programmatically: 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 Ice_Web_Portal.BO; namespace GridView___Test { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = Course.GetCourses(); GridView1.DataBind(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridViewRow row = GridView1.Rows[e.NewEditIndex]; GridView1.EditIndex = e.NewEditIndex; GridView1.DataSource = Course.GetCourses(); GridView1.DataBind(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtID = (TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]; TextBox txtCourseCode = (TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]; TextBox txtCourseName = (TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]; TextBox txtCourseTextBookCode = (TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]; Course item = new Course(); item.ID = Convert.ToInt32(txtID.Text); item.CourseCode = txtCourseCode.Text; item.CourseName = txtCourseName.Text; item.TextBookCode = txtCourseTextBookCode.Text; bool success = Course.Update(item); labMessage.Text = success.ToString(); GridView1.EditIndex = -1; GridView1.DataSource = Course.GetCourses(); GridView1.DataBind(); } } } But 2 problems are happening. (1) I need to press command buttons twice to Edit/Update. (2) Changes in the cell values are not updated in the database. I.e. edited cell values are not committing. Can anyone give me a solution?

    Read the article

  • Binding dropdown list in a gridview edit item template

    - by Renju
    i can bind the dropdownlist in the edit item template. The drop down list is having null values. protected void grdDevelopment_RowDataBound(object sender, GridViewRowEventArgs e) { DropDownList drpBuildServers = new DropDownList(); if (grdDevelopment.EditIndex == e.Row.RowIndex) { drpBuildServers = (DropDownList)e.Row.Cells[0].FindControl("ddlBuildServers"); } } also getting an error Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

    Read the article

  • Adding a GridViewRowCollection to the asp.net GridView

    - by CoffeeCode
    i have a record of a gridviewrowcollection. and i'm having issues with adding them to the grid. GridViewRowCollection dr = new GridViewRowCollection(list); StatisticsGrid.DataSource = dr; doesnt work. StatisticsGrid.Rows does have an add method, what is strange how can i add a gridviewrowcollection without creating a datatable + binding it to the datasource?? thanks in advance

    Read the article

  • gridview findcontrol in footer problem

    - by harold-sota
    I have a asp.net grid view with the property ShowFooter="True" and a item template as <FooterTemplate> <asp:DropDownList ID="Contetnt1InsertDropDownList" Width="100%" runat="server" DataSource="<%# GetValueForDropDownCombinationContent() %>" DataValueField="LOOKUP_ID" DataTextField="LOOKUP_NAME" > </asp:DropDownList> </FooterTemplate> in the code behind : Dim ddl As DropDownList = DirectCast(combinationViewGridView.FooterRow.FindControl("Loocup1InsertDropDownList"), DropDownList) in a RowCommand event the cast return a null value. Any ideas??

    Read the article

  • show data in gridview using condition

    - by Indranil Mutsuddy
    Hello, I want to check a condition in a grid view e.g. if(loginid.equels('admin')) query = select * from memberlist; else query = select * from memberlist where memberid like 'operator%'; depending on the query ther grid view will display the listof members and also where to put this code in .cs or .aspx and how? Regards Indranil

    Read the article

  • Binding Generic List Array to GridView

    - by OliverS
    Hi I have a List which returns an array of "Question". My question is how can I bind this to a grid view? When I try to call Question.Ordinal I get that it does not exist in the data source. I am using the following code: GridView1.DataSource = myList.GetQ(); GrdiView1.DataBind(); myList.GetQ() returns a List which is an array of "Question". When I set the column DataField to "!" I get the object Question. My question is how can I get the objects property? I tried "!.Ordinal" does not work. I was reading this post for reference, here, any help is greatly appreciated, thanks.

    Read the article

  • GridView in ASP.NET 2.0

    - by Subho
    How can I populate an editable Grid with data from different tables from MSSQL Server'05 writing a code behind function??? I have used: Dim conn As New SqlConnection(conn_web) Dim objCmd As New SqlDataAdapter(sql, conn) Dim oDS As New DataSet objCmd.Fill(oDS, "TAB") Dim dt As DataTable = oDS.Tables(0) Dim rowCount As Integer = dt.Rows.Count Dim dr As DataRow = dt.NewRow() If rowCount = 0 Then e.DataSource = Nothing e.DataBind() e.Focus() Else e.DataSource = dt e.DataBind() End If

    Read the article

  • Gridview tooltip

    - by Geetha
    Hi All, if (e.Row.RowType == DataControlRowType.Header) { int i = 0; foreach (TableCell cell in e.Row.Cells) { cell.Attributes.Add("title", reason[i]); i++; } } i am using this code to show tool tip in grid view.Tool tip is getting displayed when the page loads but after a click event the tool tip is not working.

    Read the article

  • Custom GridView delete button

    - by abatishchev
    How can I customize automatically generated command button, e.g. Delete? I want to add a client confirmation on deleting and in the same moment I want this button would be generated on setting AutoGenerateDeleteButton="true". Is it possible?? I can add a custom button this way: <asp:TemplateField> <ItemTemplate> <asp:LinkButton runat="server" CommandName="Delete" OnClientClick="return confirm('Delete?')">Delete</asp:LinkButton> </ItemTemplate> </asp:TemplateField> but it will be not automatically localized and will be not generated on setting AutoGenerateDeleteButton="true"!

    Read the article

  • GridView in UpdatePanel adds extra rows when sorting another grid

    - by chopps
    Hey Everyone, I'm a seeing some weird behavior that i have never seen before. I have two grid in separate UpdatePanels. I can page and sort each without any problems. Each grid is set for 10 per page. If the first grid (13 records) is paged to the second page and then i go down to the second grid (14 records) and page to the next page and the first grid adds a bunch of empty rows to the grid so it is full to show 10. There is no data in the rows...just empty rows. Each grid does this on paging and sorting. Ive stepped through the code and the the loading of the other grids never happens so it tells my AJAX is doing something to add the 'phantom' rows to the grid. Any ideas why or ways to debug this?

    Read the article

  • GridView to excel after create send mail c#

    - by Diego Bran
    I want to send a .xlsx , first I created (It has html code in it) then I used a SMTP server to send it , it does attach the file but when I tried to open it " It says that the file is corrupted etc" any help? Here is my code try { System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); // Render grid view control. gvStock.RenderControl(htw); // Write the rendered content to a file. string renderedGridView = sw.ToString(); File.WriteAllText(@"C:\test\ExportedFile.xls", renderedGridView); // File.WriteAllText(@"C:\test\ExportedFile.xls", p1); } catch (Exception e) { Response.Write(e.Message); } try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("server"); mail.From = new MailAddress("[email protected]"); mail.To.Add("[email protected]"); mail.Subject = "Test Mail - 1"; mail.Body = "mail with attachment"; Attachment data = new Attachment("C:/test/ExportedFile.xls"); mail.Attachments.Add(data); SmtpServer.Port = 25; SmtpServer.Credentials = new System.Net.NetworkCredential("user", "pass"); // SmtpServer.EnableSsl = true; SmtpServer.UseDefaultCredentials = false; SmtpServer.Send(mail); } catch( Exception e) { Response.Write(e.Message); }

    Read the article

  • Gridview adding row dynamically on RowDataBound with the same RowState (Alternate or Normal)

    - by rob waminal
    I am adding rows dynamically on code behind depending on the Row currently bounded on RowDataBound event. I want that added row to be the same state (Alternate or Normal) of the currently bounded row is this possible? I'm doing something like this but it doesn't follow what I want. I'm expecting the added row dynamically would be the same as the current row. But it is not. protected void gv_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { GVData data = e.Row.DataItem as GVData; // not original object just for brevity if(data.AddHiddenRow) { // the row state here should be the same as the current GridViewRow tr = new GridViewRow(e.Row.RowIndex +1, e.Row.RowIndex + 1, DataControlRowType.DataRow, e.Row.RowState); TableCell newTableCell = new TableCell(); newTableCell.Style.Add("display", "none"); tr.Cells.Add(newTableCell); ((Table)e.Row.Parent).Rows.Add(tr); } } }

    Read the article

  • Gridview making a column invisable

    - by flyersun
    Hi I have a grid view which is dynamically generated via C# using a DataSet. I'm passing a row ID field (from the database) to the grid view, as this is required when a user clicks to edit a records. However I don't want the user to be able to view the column. I have tried the following but it doesn’t seem to work? Could anyone suggest a way to hide the column or a better way of attaching the information to the grid view row so it can be used at a later stage. c# DataColumn ColImplantCustomerDetailsID = new DataColumn(); ColImplantCustomerDetailsID.ColumnName = "Implant ID"; ColImplantCustomerDetailsID.DataType = typeof(int); ColImplantCustomerDetailsID.Visable = false; <-- visable doens't work here. asp.net

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >