i have a table like that:-
coll'n_id price
----------- --------
1 ---- 500
1 ---- 600
2 ---- 300
2 ---- 400
2 ---- 800
3 ---- 200
4 ---- 200
and i want the output like that:-
coll'nn_id price
----------- --------
1 ------ 500,600
2 ---- 300,400,800
3 ---- 200
please suggest me how can achieve this output?it means i want for same collection_id different price come in same row sepreated by comma(,) and if the price is same for same collection_id then single price would display ,not duplicate price in same column..... plz help me..?
8 1012
please send code what u actually doing?
I think, Price column should be text. And check new price in string if it exist thn do not update column otherwise update column
ya price column is the type of string but i am not able to compare with privious row value.... and how to after comparision append to price column if
the id is same? plz send me sample code for that?
tlhintoq 3,525
Recognized Expert Specialist
Avinash_Sh:
You've asked for 'sample' code of how to fix your problem, but couldn't be bothered with supplying the code that you are currently using when asked by Alamodgal.
You've said that you not able to compare the value with the previous row. Why not? Its your code. You can do whatever you like with it. If you can't *currently* compare row 2 to row 1 before displaying row 1, then change what you've written so you can.
Since you are unwilling to provide the code you've done so far the people here have nothing more to go on, if you won't help them to help you.
actually i got the result set from my stored procedure...and assigned in a dataset and added to datatable which i explained you in table one.....and now i have to display on gridview to this datatable in format of second table....
code is like that..
i got datatable from sp
then i am assigning datasource of gird like that
grid1.datasource=datatable;
grid1.databind();
it gives me output of simple form like table1... but i want output like table 2.. what to do for that....?
tlhintoq 3,525
Recognized Expert Specialist
I believe that to do what you want to accomplish you are not going to be able to go the 'easy' route of just binding data to controls. As Alamodgal and Kunal suggested you are going to have to receive the data, process the data into formated strings that look the way you want them to, then display the formatted string.
actually i am a beginer.. so plz tell me how to compare the existing value with current value of datatable and update the second column by concatinate new value previous one to previous one...? send small code or link for that..? plzzzzzz
@avinash sh
Hiiiiiiii avinash
I dont know, what are you implement in your code. -
Sub load_data()
-
Dim query As String
-
query = "Select id from tbl_price group by id"
-
Dim ds As New DataSet
-
Dim adp As New SqlDataAdapter(query, con)
-
adp.Fill(ds)
-
gvdata.DataSource = ds
-
gvdata.DataBind()
-
-
End Sub
-
-
Protected Sub gvdata_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvdata.RowDataBound
-
If e.Row.RowType = DataControlRowType.DataRow Then
-
Dim query As String
-
Dim count As Integer
-
Dim id, price As String
-
query = "select price from tbl_price where id = " & gvdata.DataKeys(e.Row.RowIndex).Value
-
-
Dim ds As New DataSet
-
Dim adp As New SqlDataAdapter(query, con)
-
adp.Fill(ds)
-
-
-
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
-
-
price &= ds.Tables(0).Rows(i)("price") & ","
-
Next
-
Dim lbl As Label = CType(e.Row.Cells(1).FindControl("lblPrice"), Label)
-
lbl.Text = price.Substring(0, price.Length - 1)
-
-
End If
-
End Sub
-
I used gridview not a datatable. If you find any problem implement in this code. So reply me. Use this code in gridview. it definate work
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Emerson |
last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C#
Here's my scenario
I click in a cell on a DataGrid. I enter some...
|
by: Stefan Turalski \(stic\) |
last post by:
Hi,
I'm wondering if there is a way to send a method parametrs by ref when
DataTabel is a type of this value ?
I done some sort of select over DataTable columns, just by removing them
froma...
|
by: Kris Rudin |
last post by:
I am displaying a table of information on a web page, using an asp:table
that I populate dynamically. On this page I give the user the options to
group the rows by certain fields, and/or filter the...
|
by: Mike |
last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the
course of about 3 different pages. On the way out of the first of
these pages, I explicitly build the DataTable from values in...
|
by: Frans Bouma |
last post by:
Hi,
I have a serious problem with VB.NET and a DataTable derived class and I
can't figure out how to solve it. I have implemented it in C# where it
works perfectly, but I can't port one...
|
by: Doug Bell |
last post by:
Hi,
I am having problems trying to create a (temporary) DataTable from a
selection from a DataGrid (dgOrders).
dtOrdDetails is declared as a Public DataTable
Sub is:
Dim stFilter as String...
|
by: JohnR |
last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a
datagridtablestyle defined. I use the datagridtablestyle to change the
order of the columns (so they can be different than...
|
by: Anil Gupte |
last post by:
After reading a tutorial and fiddling, I finally got this to work. I can
now put two tables created with a DataTable class into a DataRelation.
Phew! And it works!
Dim tblSliceInfo As New...
|
by: Frank Hauptlorenz |
last post by:
Hello,
I recognized some days ago, that returning a DataTable blocks my
WCF-Service. Is this a known bug?
If I add this table to a new DataSet() and return this, it works.
Thank you,
Frank
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
I've got a routine that builds a table using different queries, different SQL
Tables, and adding custom fields.
It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the
table...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |