473,834 Members | 2,269 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 20 '05 #1
7 1558
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 20 '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 20 '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 20 '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 20 '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 20 '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 20 '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 20 '05 #8

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

Similar topics

0
1034
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...
7
1373
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.
6
1625
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...
4
3757
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
4536
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
1639
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)...
3
2037
by: Rushi Panchal | last post by:
Hiii I have a one textbox ,one button,one datagridm i want to fill datagrid anything type in textbox and press button than whatever value in text box is going to datagrid and so on and i don't use any databe connection just fill the datagrid throgh textbox.text value thank u
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10500
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
10543
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10213
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7753
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
5789
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4422
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
3972
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3078
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.