Get Columns With Values / Add Them And Then Divide

Feb 14, 2011

I've got some code which is working as it should but it just seems like a bit of a round about way in doing it and how to tidy it up

Here's my code

Dim TotalNumber As Double
Dim NumberFilled As String
NumberFilled = Nothing
For x = 0 To drCode2a.Tables(0).Columns.Count - 1
If Not drCode2a.Tables(0).Rows(0)(x).ToString() = "0" Then
NumberFilled += drCode2a.Tables(0).Rows(0)(x).ToString() & "-"
TotalNumber = TotalNumber + drCode2a.Tables(0).Rows(0)(x).ToString()
End If
Next
Dim delimiters As Char() = New Char() {"-"c}
Dim TotalNumberFilled As String() = NumberFilled.Split(delimiters, StringSplitOptions.RemoveEmptyEntries)
Dim AverageRating As Double = TotalNumber / TotalNumberFilled.Length
Response.Write(NumberFilled & "<br/>" & TotalNumber & "<br/>" & AverageRating)

Basically for my example NumberFilled = "1-2-" and TotalNumber = 3 and AverageRating = 1.5

It shows that 2 columns were filled out and the total they equal is 3 so the average = 1.5

As I said it works like it should but I'd like to tidy up if possible

View 2 Replies


Similar Messages:

Web Forms :: Values Of 1 Field In 4 Columns On UI / Display As Checkbox Values On UI?

Feb 8, 2010

I hv a filed in db having 60 values. I want them to be displayed as checkbox values on my UI.but i want those checkboxes as 15 values in 1 column.15 in 2nd col.15 in 3rd col.and last 15 in 4th coln. how to do it?

View 3 Replies

Divide Querystring By Label Value?

Oct 27, 2010

in my code behind how do i divide a requested querystring value by a label value?:

Label55.Text = Request["r1"]/Label71.Text;

View 3 Replies

C# - Fill Combo-box Via DataSource Using Values From Various Columns?

Jun 12, 2010

Employee emp = new Employee();
comHandledBySQt.DataSource = emp.GetDataFromTable("1");
comHandledBySQt.DisplayMember = "FirstName";

The above code displays drop list of employees first names in a combo box. I want first name and last name to be displayed. How can i do it?

I tried to include two columns FirstName and LastName as below but didn't work.

comHandledBySQt.DisplayMember = "FirstName" + " " + "LastName";

View 2 Replies

DataSource Controls :: Columns Don't Currently Have Unique Values?

May 3, 2010

I am returning a dataset from a method and trying to set one of the columns as Primary Key.

CategoryList.Tables[0].PrimaryKey = new DataColumn[] { CategoryList.Tables[0].Columns["CategoryNodeId"] };

Interestingly it gives me this error at run-time, These columns don't currently have unique values.

Now I perfectly know why this error should error, but there are no duplicate keys in this data column. I broke the code in between and bound the dataset to gridview to check if this column contains any duplicates and this is not the case. Here is the result set underneath. Have a look at the first column 'CategoryNodeId'.

CategoryNodeId
CategoryId
Name
ParentCategoryNodeId [code]...

unable to find a work around for now.

View 3 Replies

SQL Server :: How To Show Two Columns One Is The One Will Contain The Distinct Values From 'col'

Mar 30, 2011

I have a table 'tbl' and a column 'col'. The elements are like 1,1,2,2,2,3,4,4. Now I want to show two columns one is the one will contain the distinct values from 'col' like 1,2,3,4.... and second will contain the count for each of them like for above case it will be 2,3,1,2.

View 1 Replies

Javacript With A Gridview / Values Of The Bound Columns?

Apr 14, 2010

I have got a simple gridview two bound columns and one template column with a textbox.

I need to get the values of the bound columns is this possible. I need to times the textbox with the bound column value

Now i can get the textbox value using

// var sumInput = null;
// var tempValue = 0.0;
// var retail = 0.0;
// function Load(sender, args) {
// sumInput = sender;
// }
// function Blur(sender, args) {
// sumInput.set_value(tempValue + (sender.get_value()));
// }
// function Focus(sender, args) {
// tempValue = sumInput.get_value() - (sender.get_value());
// }

View 4 Replies

MVC :: Divide Master Page Into Two Portions?

Nov 11, 2010

I want my master page divide into two portions : left and right using DIV tags.

In the left, will be render the menus and on clicking those you I need to invoke MVC actions using AJAX and render partial views on the right-side.

I want something similar to this site:

[URL]

View 1 Replies

Forms Data Controls :: Getting Values From The Columns In A Gridview?

Feb 9, 2010

I want to get the values from a cell in a gridview so can I do that without selecting a row. Its something like this I have a drop downmenu and based on the value selected in the dropdown menu I have to change the presentation of gridview without going to the database.

View 3 Replies

Sql Server - Gridview Highlight Max Values In Multiple Columns?

Mar 29, 2011

I have a gridview that shows, for example, a baseball team's statistics. It's a standard sports stats grid - the rows show statistics for each player and the columns show the specific stat for the each player.

Easy enough so far. But what I would then like to do is style (highlight or bold) the Max or Min (the team leader) of each stat column. For example, Player A may only lead in one or two categories, so we cannot style the entire row. If Player A just leads the team in strikeouts, I just want to style the number of strikeouts he had (THAT cell only).

What's the best way to handle this? Make SQL Server do all the work and in effect, rank EVERY stat of each player, effectively doubling the number of columns (e.g. col: AB, col: ABRank). Or do I let the rowdatabound event of the gridview handle this?

If I chose the latter, I think I would get the Max of every statistical category from the datatable before binding (e.g. store them in a local variable) then on rowdatabound, if they match the value, apply the style.

View 3 Replies

Creating A Function To Calculate Two Database Columns / Values?

May 11, 2010

I am using ASP.NET 2008 Visual Basic Language. I tried to create a function that multiply two values from two different tables and get the result presented in a label. The value is retrieved by referring to the primary key after the user selects from a DropDownList which is in another page using sessions.

I tried to build this code in the Load_Page event but it didn't display for me the total.

[Code]....

View 4 Replies

Forms Data Controls :: How To Compare The Values Of The Columns

May 23, 2010

If I have a GridView with 4 columnsthree of them displaying different prices of the same product and the fourth one should display the cheapest..how can I compare the values of the columns ??

View 5 Replies

DataSource Controls :: Set Up SQL Table Columns To Have Multiple Values?

Mar 9, 2010

Is it possible in to set up an SQL table column to have multiple values? Or would I have to put my values into a new table and link it to the original one?

View 6 Replies

Web Forms :: How To Divide Webpage Content In A Page

Jan 13, 2010

i need to divide my page content in a page.

on left side i have a Tree Control on the basis of that i have to refresh the right side details element into div. Scrolling tree should not disturbed the right side elements as well as right side details should not scroll the page or tree control scrolling.

How can i achieve this task?

View 2 Replies

JQuery :: Divide A Table In A Repeater In Two Part?

Jan 6, 2011

how to divide a table in a reapter in two part using jquery

a repeater contain 31 record how to

id name
1 a
2 b
3 c
4 d
............................
......................
.....................
31.......... x

how to divide in two table i means one table left side and second is right side

Left side
1........................a
.......................
16.....................m
right side
17.....................n
.........................
.......................
31.........................x

View 1 Replies

Web Forms :: Divide The Navigation Of Site Between 2 Menus?

Jan 4, 2010

i want to display my navigation in 2 horizontal menus, one on the top, the other on the bottom. I also want to use sitemap since it ease the maintenance of links. Is there a simple way to achieve this ? (I am not talking about Parent child, say i want to display the first 8 nodes in up menu and the left in the bottom menu.)

View 5 Replies

DataSource Controls :: Divide Records Into Batches?

Jun 14, 2010

I would like to divide a table of 100000 records into batches of 20000. I realize I could use the select top....

but is there a faster way to do this.

View 1 Replies

Web Forms :: Divide Master Page Into Two Sections

May 7, 2015

I need to separate the master page as left side and right side.

In my left side i need to show the images without buffering and the content as a marque text using jquery.....

View 1 Replies

Web Forms :: Insert 8 Different Selected Values From A CheckBoxList Into 8 Different Columns Of A Database

Aug 1, 2010

I am trying to insert 8 different selected values from a CheckBoxList into 8 different columns of a database. As it now, I am only able to concatenate all 8 selections into a single string in one column. But this is not what I want to do. In my DB I have Column1, 2, 3, 4, 5, 6, 7, 8. Is there any way of getting this done?

View 5 Replies

Forms Data Controls :: Cannot Access The Non Visible Columns Values

Mar 18, 2010

I've created a gridview having an Id column whose visible property is set to false, because I don't want users to see that column. Now when user clicks on the edit button in a particular row I want to fetch the id of the cell in the Id column of that particular row. So, for that purpose I used -

void GridView_RowEditing(object sender, GridViewEditEventArgs e)
{
string Id = GridView.Rows[e.NewEditIndex].Cells[0].Text;
}

In the above code, Cells 0th index is the column index whose visible property is kept false. Now the problem I face here is that if the columns visible property is true then I can easily fetch the contents of that particular cell with the above code. But, in invisible mode I get only "" value i.e. I don't get the text or the content of that cell. Why does it happen? I don't face this problem with DataGrid Control used with 1.0 and 1.1 version. And how to resolve it or in this case is there another way of fetching the content of the invisible cell?

View 4 Replies

Data Controls :: GridView Columns Values Must Remain Fix During Edit

Sep 4, 2012

I didnt use bound field here.as it is simple grid view with auto generate columns. I want to make some columns Editable while some should not be editable

<asp:GridView ID="noticeDetails" runat="server" AutoGenerateEditButton="True"
onrowediting="noticeDetails_RowEditing1"
onrowupdated="noticeDetails_RowUpdated1"
onrowupdating="noticeDetails_RowUpdating1"
BorderWidth="1px" Width="100%" CellPadding="10">
</asp:GridView>

View 1 Replies

Web Forms :: Masterpage Divide Pages Into Left / Top / Right / Bottm

Feb 24, 2010

I have a master page that I want to use acorss my application.

Now I want all my pages to have left, top, right, bottm section uniformily accross my site.

I am not very good at css, could anyone show me how to use divs, css etc.

I want to a an left menu, a top menu, a right ad section and a bottom footer section,

View 2 Replies

Forms Data Controls :: Can Divide A Webpage Into Sections

Mar 15, 2011

i have a web page and what i was wanting to do is divide it into lets say 4 quadrants, and in each quadrant i have a control ( a gridview whaich has data dound to it) .

when a user clicks on lets say one of the four the grid does a drill down and display the results in that particular quadrant only while the others are left untouchd .,

how can i go about doing this ?

View 3 Replies

SQL Server :: Solve Divide By Zero Exception In SQL Stored Procedure?

Jan 30, 2011

When I am executing my stored procedure it is throwing Divide By zero Exception. Because In my database there is no data for some months. How can I solve this?

View 5 Replies

Forms Data Controls :: Adding All The Values In Multiple Columns In A Gridview?

May 14, 2010

I'm just wondering if anyone can assist me with this gridview problem

I have this Sql statement that outputs a gridview like this

Job Location Activity 1 Activity 2 Activity 3

Job1 Location1 0 0 1

Job2 Location2 1 0 1

Job3 Location3 0 1 0

* These columns are placeholders

I want to include a footer total that looks like

Job Location Activity 1 Activity 2 Activity 3

Job1 Location1 0 0 1

Job2 Location2 1 0 1

Job3 Location3 0 1 0

Final Total 4

Im not binding the database to the gridview via design view I'm binding it programatically in the default.aspx.cs file

So far the only tutorials I've encountered are ones the have the database bound through design view and gridviews with only one column that can be added. In my particular example I have multiple columns that need to be added and I have already bound the data to the gridview.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved