Please refer to the simple table below.
I don't know how to save all data.
GRIDVIEW:
COLUMN1| COLUMN2 | COLUMN3 | COLUMN4 | COLUMN |....
ROW1 | 100 | 105 | 109 | 112 |
ROW2 | 55 | 58 | 62 | 67 |
ROW3 | 71 | 75 | 79 | 83 |
ROW4 | 204 | 209 | 216 | 221 |
ROW..
gridviewRowsColumns
Notes:
First column = stock code, (in tag property, contain ID)
Columns COLUMN1, COLUMN2, COLUMN3.... sales prices for stock.
Related
I have a gridview which has 2 header rows as below
| Name | Subject1 | Subject2 |
| | T | V | T | V |
|-------|-----|-------|-----|-------|
| John | 80 | 20 | 78 | 18 |
| Ann | 75 | 18 | 68 | 15 |
The grid view data source is a data table which i have created dynamically. Header rows are also created dynamically.
Now I want to set tooltip for the second header row as 'Theory' for 'T' and 'Viva' for 'V'.
By using gvMarks.HeaderRow.Cells[1].Tooltip, I am able to set tooltip only for the first header row.
If I use gvMarks.Rows[1].Cells[1].Tooltip, I am able to access only the grid data rows.
How can I access the second header row so that I can set the tooltip programatically.
I have a table in SQLserver with some values as following
+----------+------+-------+-------+-----+--------+
| MonTime | Temp | Steam | Water | Air | Vacuum |
+----------+------+-------+-------+-----+--------+
| 16:08:08 | 0 | 38 | 57 | 76 | 95 |
| 16:09:08 | 9 | 28 | 47 | 66 | 85 |
| 16:10:08 | 18 | 37 | 56 | 76 | 95 |
| 16:11:08 | 9 | 28 | 47 | 66 | 85 |
| 16:12:08 | 9 | 28 | 47 | 66 | 85 |
| 16:13:08 | 18 | 37 | 56 | 75 | 94 |
| 16:14:08 | 9 | 28 | 47 | 66 | 85 |
+----------+------+-------+-------+-----+--------+
I need to create a line chart in winform application. where x is timeline "MonTime" and y is values and a line for each col "Temp, Steam, Water, etc"
I don't know how to accomplish this. Any help??
Thanks for your support. The problem was with the MonTime datatype "Time(0)" this datatype is not supported by Chart control . I converted it to datetime in SQL and then set it up as Time in chart control X value type.
I am trying to figure out how to join two respective datarows into single datarow in dataset through Department column Name.
In provided dataset output i want to join Gastroenterology and Medical Gastroen(two datrows) through column name to single datarow (similar to Required Final dataset Output with Merged Rows).
Need Your ideas/help how it can be accomplished in asp.net and/or C#.
DataSet Output
Department Male Visit Female Visit Total Count
---------- ---------- ------------ -----------
Endocrinology 10 20 30
Gastroenterology 15 25 40
General Medicine 25 05 30
Medical Gastroen 30 20 50
Required Final Dataset Output with Merged Rows
Department Male Visit Female Visit Total Count
---------- ---------- ------------ -----------
Endocrinology 10 20 30
Gastroenterology 45 45 90
General Medicine 25 05 30
I think you must use joining for this in your database query. that would be better.
Table A
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+
Table B.
+-----+---------------------+-------------+--------+
| OID | DATE | ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 | 3 | 3000 |
| 100 | 2009-10-08 00:00:00 | 3 | 1500 |
| 101 | 2009-11-20 00:00:00 | 2 | 1560 |
| 103 | 2008-05-20 00:00:00 | 4 | 2060 |
+-----+---------------------+-------------+--------+
SQL QUERY
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
INNER JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
Resulted Table:
+----+----------+--------+---------------------+
| ID | NAME | AMOUNT | DATE |
+----+----------+--------+---------------------+
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
+----+----------+--------+---------------------+
I hope it will help you.
You can Do something like this.
DataTable _dataTable = new DataTable();
DataRow _dataRow1 = null;
_dataTable.TableName = "Products";
_dataTable.Columns.Add("ID",typeof(int));
_dataTable.Columns[0].AutoIncrementSeed = 1;
_dataTable.Columns[0].AutoIncrement = true;
_dataTable.Columns.Add("ProductsName");
_dataTable.Columns.Add("Price");
_dataRow1 = _dataTable.NewRow();
_dataRow1["ProductsName"] = "Sony Laptop";
_dataRow1["Price"] = "15000";
_dataTable.Rows.Add(_dataRow1);
DataRow _dataRow2 = null;
_dataRow2 = _dataTable.NewRow();
_dataTable.Rows.Add(_dataRow2);
_dataRow2["ProductsName"] = "LG Laptop";
_dataRow2["Price"] = "15000";
DataSet _dataSet = new DataSet();
_dataSet.Tables.Add(_dataTable);
I'm new to ASP.NET, I have only experiences in C# Windows Form and SQL Server. Now I have starting my new project in ASP.NET MVC and already have database from my customer. It has two model included some same column name like this:
Table 1
---------------------------------
| Location | Item | Model | Tag |
---------------------------------
| 1 | 10 | A5 | 221 |
| 2 | 10 | A6 | 233 |
| 3 | 12 | A8 | 332 |
| 4 | 15 | C1 | 223 |
Table 2
-------------------------------------------------
| Location | Item | Model | Tag | DWeek | DYear |
-------------------------------------------------
| 1 | 10 | A5 | 221 | 01 | 15 |
| 2 | 10 | A6 | 233 | 01 | 15 |
| 3 | 12 | A8 | 332 | 02 | 15 |
| 4 | 15 | C1 | 223 | 03 | 15 |
I just want to show the data which have same Location and Item in one table, I don't know how to query in Entity framework, I have only know how to code by SQL, and I think it seem to be like this:
select
r.Location
,r.Item
,d.Location
,d.Item
,d.DWeek
,d.DYear
,r.Model
,r.[Tag No]
,d.[Tag No]
from Register r, Due d
where r.Location = d.Location
and r.Item = d.Item
My question is how to query like this in Entity framework for show data in a view, and is it possible to update and create two model in the same time?
I am using Lambda Expression
var Query=Register.Join(Due,r=>r.Location,d=>d.Location,(r,d)=>new {r,d}).Where(
X=>X.r.Location = X.d.Location && X.r.Item = X.d.Item).Select(X=>new {
LOCATION_1 =X.r.Location;
ITEM_1=X.r.Item;
LOCATION_2=X.d.Location;
ITEM_2=X.d.Item;
DWEEK=X.d.DWeek;
DTEAR=X.d.DYear;
MODEL=X.r.Model;
TAGNO_1=X.r.Tag_No;
TAGNO_1=X.d.Tag_No;
}).ToList();
I would like to divide a worksheet into multiple files.
I have a worksheet with about 10,000 rows. there is fancy formatting, conditional formatting, nice colors, and I want to preserve all of these attributes.
I need to divide this worksheet up.
the input would be:
+-------+----+----+----+----+
| Alex | 45 | 6 | 23 | 56 |
| Alex | 61 | 47 | 56 | 56 |
| Liza | 49 | 70 | 34 | 37 |
| Alex | 33 | 30 | 22 | 39 |
| Tommy | | 66 | 62 | 29 |
| Liza | | 38 | 49 | 80 |
| Alex | 23 | 56 | 56 | 39 |
| Liza | 32 | 46 | 40 | 43 |
| Liza | | 90 | 24 | 38 |
| Tommy | 38 | 10 | 52 | 23 |
| Nancy | 35 | 36 | 23 | 25 |
+-------+----+----+----+----+
and the output would be separate files like this (please keep in mind i want to preserve all the fancy formatting, and thus the solution has work directly with excel, and not with just CSV (because csv cannot retain formatting))
end products:
+------+----+----+----+----+
| | | | | |
| Alex | 45 | 6 | 23 | 56 |
| Alex | 61 | 47 | 56 | 56 |
| Alex | 33 | 30 | 22 | 39 |
| Alex | 23 | 56 | 56 | 39 |
+------+----+----+----+----+
and
+------+----+----+----+----+
| | | | | |
| Liza | 49 | 70 | 34 | 37 |
| Liza | | 38 | 49 | 80 |
| Liza | 32 | 46 | 40 | 43 |
| Liza | | 90 | 24 | 38 |
+------+----+----+----+----+
and
+-------+----+----+----+----+
| | | | | |
| Nancy | 35 | 36 | 23 | 25 |
+-------+----+----+----+----+
and
+-------+----+----+----+----+
| | | | | |
| Tommy | | 66 | 62 | 29 |
| Tommy | 38 | 10 | 52 | 23 |
+-------+----+----+----+----+
the solution can be a combination of VBA/.NET. please note that i need multiple files as outputs.
what is the quickest way to get this working? thanks so much for any input!
please note that this is excel 2007 and later
I done this before.
You can use this code:
Option Explicit
Sub getInformations()
Dim varName As String
Application.ScreenUpdating = False
'Replace Tabelle1 with the name of your sheet where the Informations are
Worksheets("Tabelle1").Select
Worksheets("Tabelle1").Copy After:=Sheets("Tabelle1")
Sheets("Tabelle1 (2)").Select
Sheets("Tabelle1 (2)").Name = "Temp"
Do Until Range("A1").Value = vbNullString
varName = Range("A1").Value
Workbooks.Add
'Change the Path where you want to save the File
ActiveWorkbook.SaveAs ("C:\Documents and Settings\vgellhom\Desktop\" & varName & ".xls")
'Change The Name of the Excel Workbopk to the Name of the Workbook with the Names
Workbooks("Data.xls").Activate
Sheets("Temp").Select
varName = Range("A1").Value
Do While True
Cells.Find(What:=varName).Activate
Range(ActiveCell.Row & ":" & ActiveCell.Row).Select
Selection.Copy
Workbooks(varName & ".xls").Activate
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Activate
'Change The Name of the Excel Workbopk to the Name of the Workbook with the Names
Workbooks("Data.xls").Activate
Sheets("Temp").Select
Selection.Delete Shift:=xlUp
If Not Cells.FindNext(After:=ActiveCell) Is Nothing Then
Cells.Find(What:=varName).Activate
Else
Exit Do
End If
Loop
Workbooks(varName & ".xls").Activate
'Change the Path where you want to save the File
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = True
Workbooks(varName & ".xls").Close
Loop
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Hope that helps you...
Since Excel formatting is usually a big pain in the a**, I would recommend to try a following solution:
Calculate and store all the unique keys.
Create a copy of a file for each key (like file_Alex.xls[x], file_Liza.xls[x] and so on).
Process each file, deleting all non-key rows, thus all key entries are left. Also because you are only deleting entire rows all the formatting in file is retained.
This is very unoptimized, but also extremely simple solution. If it's a one-time job, it should do just fine.