473,803 Members | 4,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fill DataGrid

Hi,

How can I fill a datagrid without accessing to a database or any type of
file, only filling with a command button like this:
I have 3 textboxes that I must fill, and a button that when clicked pass
text of this 3 textboxes to my datagrid.

I want to manage (edit , update, etc) a datagrid but without accessing
DataBase. The unique interaction with that DB is a button that save all that
I have in datagrid into DB.

Hope you understand.

--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
Nov 18 '05 #1
7 1372
Hi Ruca,

Please tell that you are using a WebDatagrid when you ask this in the
language.VB newsgroup.

I hope this was where you where looking for.

Cor
..
\\\
Dim ds As New DataSet
Dim dt As New DataTable("Ruca ")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr( i + 65))
dt.Columns.Add( dc)
Next
'And 12 rows every column filled with the same letter
For i As Integer = 0 To 11
dt.Rows.Add(dt. NewRow)
For y As Integer = 0 To dt.Columns.Coun t - 1
dt.Rows(i)(y) = Chr(i + 48)
Next
Next
ds.Tables.Add(d t)
datagrid1.datas ource=dt.tables ("Ruca")
datagrid1.datab ind
////

I hopethis helps?
Cor
Nov 18 '05 #2
And Can I update this datatable if I want? How?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Cor Ligthert" <no**********@p lanet.nl> escreveu na mensagem
news:uQ******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi Ruca,

Please tell that you are using a WebDatagrid when you ask this in the
language.VB newsgroup.

I hope this was where you where looking for.

Cor
.
\\\
Dim ds As New DataSet
Dim dt As New DataTable("Ruca ")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr( i + 65))
dt.Columns.Add( dc)
Next
'And 12 rows every column filled with the same letter
For i As Integer = 0 To 11
dt.Rows.Add(dt. NewRow)
For y As Integer = 0 To dt.Columns.Coun t - 1
dt.Rows(i)(y) = Chr(i + 48)
Next
Next
ds.Tables.Add(d t)
datagrid1.datas ource=dt.tables ("Ruca")
datagrid1.datab ind
////

I hopethis helps?
Cor

Nov 18 '05 #3
Hi Ruca,

You can put it in a session just by
session("ds") = ds

Updating a field can be something as (typed here watch typos)
\\\\
dim ds as new dataset = session("ds")
ds.tables(0).ro ws(index).item( fieldindex) = myvalue
///
or if you do a lot you can make it yourself more simple by
\\\
dim dr as datarow = ds.tables(0).ro ws(inded)
dr(fieldindex) = myvalue
///
I assume than you know the rest yourself?

If not feel free to ask again.

Cor
Nov 18 '05 #4
I have this:

Dim dt As DataTable
dt = Session.Item("m yDt")

strCd = CStr(CType(E.It em.FindControl( "edCod"), TextBox).Text)
dt.Rows(E.Item. ItemIndex).Item ("Cod") = strCd

dgTeste.DataSou rce = dt
dgTeste.DataBin d()

Session.Item("m yDt") = dt

but it gives me an error saying: "Column 'Cod' is read only."
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
"Cor Ligthert" <no**********@p lanet.nl> escreveu na mensagem
news:uB******** ******@TK2MSFTN GP09.phx.gbl...
Hi Ruca,

You can put it in a session just by
session("ds") = ds

Updating a field can be something as (typed here watch typos)
\\\\
dim ds as new dataset = session("ds")
ds.tables(0).ro ws(index).item( fieldindex) = myvalue
///
or if you do a lot you can make it yourself more simple by
\\\
dim dr as datarow = ds.tables(0).ro ws(inded)
dr(fieldindex) = myvalue
///
I assume than you know the rest yourself?

If not feel free to ask again.

Cor

Nov 18 '05 #5
Hi Ruca,

I did not try it this way, however did you try it with a
Dim dt As New DataTable
dt = Session.Item("m yDt")


Now you have set a reference to your Session item in my idea.

When it does not work give a message, than I check it deeper.

Cor
Nov 18 '05 #6
It gives me the same error.
"Cor Ligthert" <no**********@p lanet.nl> escreveu na mensagem
news:uy******** ******@TK2MSFTN GP09.phx.gbl...
Hi Ruca,

I did not try it this way, however did you try it with a
Dim dt As New DataTable
dt = Session.Item("m yDt")


Now you have set a reference to your Session item in my idea.

When it does not work give a message, than I check it deeper.

Cor

Nov 18 '05 #7
Hi Ruca,

I was not able to do it completly dynamicly, however here a sample with what
I have strugled this morning. (And it works)

I hope it works for you as well?

Cor
\\\\In the HTML page in the datagrid
<Columns>
<asp:EditComman dColumn ButtonType="Pus hButton" UpdateText="Upd ate"
CancelText="Can cel" EditText="Edit" ></asp:EditCommand Column>
<asp:BoundColum n DataField="A"></asp:BoundColumn >
<asp:BoundColum n DataField="B"></asp:BoundColumn >
<asp:BoundColum n DataField="C"></asp:BoundColumn >
</Columns>
///
\\\
Dim dt As New DataTable("Ruca ")
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
For i As Integer = 0 To 2
Dim dc As New DataColumn(Chr( i + 65))
dt.Columns.Add( dc)
Next
For i As Integer = 0 To 9
dt.Rows.Add(dt. NewRow)
For y As Integer = 0 To dt.Columns.Coun t - 1
dt.Rows(i)(y) = Chr(i + 48)
Next
Next
DataGrid1.DataS ource = dt
DataGrid1.DataK eyField = dt.Columns(0).C olumnName
DirectCast(Data Grid1.Columns(1 ), BoundColumn).Re adOnly = True
DataGrid1.DataB ind()
Session.Item("d t") = dt
Else
dt = DirectCast(Sess ion.Item("dt"), DataTable)
DataGrid1.DataS ource = dt
DirectCast(Data Grid1.Columns(1 ), BoundColumn).Re adOnly = True
DataGrid1.DataK eyField = dt.Columns(0).C olumnName
End If
End Sub
Private Sub DataGrid1_Cance lCommand1(ByVal source _
As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.Cance lCommand
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind()
End Sub
Private Sub DataGrid1_EditC ommand1(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.EditC ommand
DataGrid1.EditI temIndex = e.Item.ItemInde x
DataGrid1.DataB ind()
End Sub

Private Sub DataGrid1_Updat eCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.Updat eCommand
Dim dv As New DataView(dt)
dv.RowFilter = dt.Columns(0).C olumnName & "=" _
& DataGrid1.DataK eys(e.Item.Item Index).ToString ()
dv(0)(1) = DirectCast(e.It em.Cells(2).Con trols(0), TextBox).Text()
dv(0)(2) = DirectCast(e.It em.Cells(3).Con trols(0), TextBox).Text
Session.Item("d t") = dt
End Sub
End Class
///
Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1033
by: Bil Muh | last post by:
Hello Developers, I would like to fill a data grid on my "Windows Forms (.NET)" by a background thread. I read some data from a binary file. With the information read from this file, I create Columns and Rows dynamically, then I fill them. I can do this operation. But, when the numbers of rows and columns are much, my application uses the 99% of CPU and stops working for other works. Fot this reason, I tried to assign this job to a...
6
1622
by: JeffB | last post by:
I have tried several different methods of getting a datagrid to fill with information. Below is the code I'm now using. When viewed in the browser and the text box filled with a parameter value (i.e. CA for Calif), the datagrids header is displayed when the button is clicked, but no data is displayed. I used SQL Profiler and can see that the query comes across with the parameter, and if I take that query string and use it exactly in Query...
7
1558
by: ruca | last post by:
Hi, How can I fill a datagrid without accessing to a database or any type of file, only filling with a command button like this: I have 3 textboxes that I must fill, and a button that when clicked pass text of this 3 textboxes to my datagrid. I want to manage (edit , update, etc) a datagrid but without accessing DataBase. The unique interaction with that DB is a button that save all that I have in datagrid into DB.
4
3755
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure and username, password etc will be exactly the same for each server, the only thing that will change is the server name. Idealy I would like to get the server names from a seperate dataset so there could be any number of servers, allthough in...
4
3297
by: jaYPee | last post by:
I have already done some code to fill the datagrid. my problem is that the fill method is too slow after executing my code. here is the scenario. i have a parent/child form. all is datagrid. one datagrid is a parent and the other is a child. now when i finish encoding data from the first datagrid (which is the parent) i have to click the check box button on that grid and fill the 2nd grid w/ the data from the other table base on the...
4
4535
by: jaYPee | last post by:
I have 1 dataset called "dataset1" that contains 2 tables called "course" and "courseload". in my form i have a datagrid. the datasource of this datagrid is "dataset1" and the datamember is "courseload". here's the fields of every table in my dataset. "Course" table CourseID
2
1635
by: Brett | last post by:
I have the following code in VS Studio .NET 2005 beta: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DataAdapter1.Fill(DataSet1) End Sub Where a database connection has been made during design time and I can preview data. The above line gives a "specified method is not supported
1
7118
by: Mrozu | last post by:
Hi I need execute SELECT SQL query in DataSet. No in SQL server(da.selectcommand) and fill dataset, only show in datagrid filtered by select-where query records from dataset:) For example I fill dataset(ds) da.selectcommand.commandtext="select * from xxx" da.fill(ds.tables(0)) and when i write
2
5232
by: MDB | last post by:
Hello All, I have a data grid that I fill using a dataset. The results of the query has around 15 columns and 500 rows (and growing). The reason I am using the datagrid is so the end users can auto sort and page so I would like to keep using the datagrid. My problem is that when I call DataAdapter.Fill, it takes a very long time and is even causing the web page to time out. Does anyone know why the fill is taking so long (15-20 sec)...
0
9703
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7604
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4275
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 we have to send another system
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.