| | |
problem with the gridview
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 60
Reputation:
Solved Threads: 1
0
#11 Nov 11th, 2009
ASP.NET Syntax (Toggle Plain Text)
Dim datatable As New Data.DataTable datatable = DirectCast((SqlDataSource1.[Select](DataSourceSelectArguments.Empty)), DataView).Table Dim dataRow As Data.DataRow = datatable.NewRow() datatable.Rows.InsertAt(dataRow, 0) GridView1.DataSource = datatable GridView1.DataBind()
Data properties on data control 'GridView1' such as DataSource, DataSourceID, and DataMember cannot be changed during the databinding phase of the control.
what's actually wrong in this
•
•
Join Date: Dec 2008
Posts: 43
Reputation:
Solved Threads: 1
0
#14 Nov 12th, 2009
if u want to add rows to datatable at runtime try this
ASP.NET Syntax (Toggle Plain Text)
Dim dataRow As Data.DataRow = datatable.NewRow() dataRow .Item("TableID") = 0 datatable.Rows.Add(dataRow )
•
•
Join Date: May 2009
Posts: 60
Reputation:
Solved Threads: 1
0
#16 Nov 13th, 2009
why is this exception System.NullReferenceException: Object reference not set to an instance of an object. when i'm using this code...........what's wrong with this code
Protected Sub gridview1_databound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
Dim datatable As New Data.DataTable
datatable = CType(GridView1.DataSource, Data.DataTable)
Dim dataRow As Data.DataRow
dataRow = CType(GridView1.DataSource, Data.DataRow)
'dataRow.Item("serial no") = 0
'dataRow.Item("description") = 0
'dataRow.Item("making") = 0
'dataRow.Item("equipment no") = 0
'dataRow.Item("quantity") = 0
'dataRow.Item("total packets") = 0
datatable.Rows.Add(dataRow)
GridView1.DataSourceID = SqlDataSource1.ID
GridView1.DataBind()
End Sub Last edited by mshravs; Nov 13th, 2009 at 3:31 am.
•
•
Join Date: Jun 2009
Posts: 452
Reputation:
Solved Threads: 82
0
#17 Nov 13th, 2009
You need to use DataTable.NewRow to create new DataRow object with the same schema as the DataTable.
Try this.
Try this.
Protected Sub gridview1_databound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
Dim datatable As New Data.DataTable
datatable = CType(GridView1.DataSource, Data.DataTable)
If Not datatable Is Nothing Then
Dim dataRow As Data.DataRow
'dataRow = CType(GridView1.DataSource, Data.DataRow)
dataRow = datatable.NewRow()
'dataRow.Item("serial no") = 0
'dataRow.Item("description") = 0
'dataRow.Item("making") = 0
'dataRow.Item("equipment no") = 0
'dataRow.Item("quantity") = 0
'dataRow.Item("total packets") = 0
datatable.Rows.Add(dataRow)
End If
GridView1.DataSourceID = SqlDataSource1.ID
GridView1.DataBind()
End Sub Last edited by Ramesh S; Nov 13th, 2009 at 4:44 am.
•
•
Join Date: May 2009
Posts: 60
Reputation:
Solved Threads: 1
0
#18 Nov 13th, 2009
then what this error System.Web.HttpException: Data properties on data control 'GridView1' such as DataSource, DataSourceID, and DataMember cannot be changed during the databinding phase of the control.
says
and the code pointing to
says
and the code pointing to
ASP.NET Syntax (Toggle Plain Text)
GridView1.DataSourceID = SqlDataSource1.ID
![]() |
Similar Threads
- im getting problem with gridview (Community Introductions)
- Ajax post back problem when using GridView with Object Data Source (ASP.NET)
- Orientation Changing Problem with Gridview (ASP.NET)
- Open a Modal Pop Up From a LinkButton In a GridView (ASP.NET)
- Open a Modal Pop Up from a Hyperlink in A GridView (ASP.NET)
- UPDATE button of gridview not working (ASP.NET)
- problem about gridview (VB.NET)
- Empty gridview (ASP.NET)
- gridview paging problem (ASP.NET)
- Problem with GridView (C#)
Other Threads in the ASP.NET Forum
- Previous Thread: help regarding session
- Next Thread: How to reduce image weight using asp.net
Views: 753 | Replies: 17
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net browser button c# checkbox click commonfunctions confirmationcodegeneration connection css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist edit editing expose feedback flash form formatdecimal forms formview google grid gridview hosting iframe iis javascript jquery list listbox login microsoft migration mono mouse mssql multistepregistration news numerical object objects panelmasterpagebuttoncontrols parent problem project radio reportemail richtextbox rotatepage save schoolproject search security services session silverlight smartcard software sql sql-server sqlserver2005 suse textbox theft tracking unauthorized update validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice youareanotmemberofthedebuggerusers





