Forms Data Controls :: Get The Datasource Of A Gridview?

Jan 6, 2010

I am using a gridview with sqldatasource. How to get back the datasource in the codebehind ?

View 2 Replies


Similar Messages:

Forms Data Controls :: Gridview Will No Longer Show The Data - Datagrid Datasource = Null

Feb 25, 2011

I am familiar with populating a gridview with data. I am able to bind the Data pulled from the database into the gridview

gridview.DataSource = myDataTable;
gridview.Databound.

If I write the following code, teh gridview will no longer show the data

gridview.DataSource = null;
gridview.Databound.

My question is , I want to make the same thing with a user control that contain a gridview. when I use the user control in an aspx page, I am able to populate it with data, but when I try to make this code, the Datasource does not show, instead, I see .DV. So I tried this code but then , I do not see DataSource property instead I see DV (DataView), when I put .DV = null, I get an error message that the object is not in existed. any idea how to clear the user control gridview from its data.

View 2 Replies

Forms Data Controls :: GridView And Swap The Datasource

Feb 10, 2010

I have a GridView and can swap the datasource just fine with code. However, The GridView also has a TemplateField with a dropdown connected to a different datasource. How can I swap that one with code too? I don't see how to drill down to find it. I've found stuff on line about accessing the TemplateFields with code, but it seemed to complex for the simple task I am trying to do.

View 3 Replies

Forms Data Controls :: Gridview And Excel As Datasource?

Mar 26, 2010

im using an excel file as a datasource for my gridview...i can pull all the data into the gridview fine. i am now hoping to allow the user to update the data in the excel file through the gridview. is it possible to update the excel file in this format i.e. allow the user the read/update the excel file as if its a database. i see some references in google that its not possible to update the excel file as the writeout causes problems. does anyone have this working...or should i look into trying to use another datasource.

i was hoping to use an excel file as the app is on a shared server and it would be handy just to have the excel file in the app folder as there is not much data involved.

View 2 Replies

Forms Data Controls :: 'DataSource' Is Not A Member Of 'gridview'.

Oct 17, 2010

I have the following code that gives me the error "'DataSource' is not a member of 'gridview'.".

what's wrong here? I'm working in the page load of my aspx page

[Code]....

View 1 Replies

Forms Data Controls :: Cant Get New Value From Gridview With Datable Datasource

Dec 16, 2010

I have read many, many articles about this issue and still cannot fix my gridview. It is a simple datagrid with a couple readonly fields and then one field is available for edit. I cannot get the new value the user enters into the grid for update... My grid can delete and cancel. I am dynamically binding and know that I have to handle this but I cannot get teh changed quanitity value out of the grid.

This is what is failing...

'The value that changed is blank but I can see the read only values here!!
hfQuantity.Value = gvCart.Rows(e.RowIndex).Cells(2).Text.ToString()

Here is my gridview:

<asp:GridView
ID="gvCart"
runat="server"
AutoGenerateColumns="False"
EnableTheming="False"
GridLines="None"
DataKeyNames="PRDID">
<Columns>
<asp:BoundField
HeaderText="Vendor Number"
DataField="VNDNO"
ReadOnly="True">
</asp:BoundField
<asp:BoundField
HeaderText="Product ID"
DataField="PRDID"
ReadOnly="True"
HeaderStyle-Width="90px"
ItemStyle-Width="90px">
</asp:BoundField>
<asp:BoundField
HeaderText="QUANTITY"
DataField="QUANTITY"> </asp:BoundField>
<asp:CommandField
ShowEditButton="True"
HeaderStyle-Width="60px"
ItemStyle-Width="60px"
CausesValidation="false">
</asp:CommandField>
</Columns>
</asp:GridView>

Code behind:

Private Sub gvCart_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvCart.RowEditing
gvCart.EditIndex = e.NewEditIndex
gvCart.DataSource = Session("CartTable")
gvCart.DataBind()
End Sub
Private Sub gvCart_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvCart.RowUpdating
'Find the row that was clicked for updating.
Dim row As GridViewRow = gvCart.Rows(e.RowIndex)
'Change the edit index to -1
gvCart.EditIndex = -1
If row IsNot Nothing Then
'The value that changed is blank but I can see the read only values here!!
hfQuantity.Value = gvCart.Rows(e.RowIndex).Cells(2).Text.ToString()
Dim myDatatable As New DataTable
'Find the Control in the grid.
myDatatable = Session("cartTable")
For i As Integer = 0 To myDatatable.Rows.Count - 1
If e.RowIndex = i Then
myDatatable.Rows(i)(2) = hfQuantity.Value
Session("cartTable") = myDatatable
gvCart.DataSource = Session("CartTable")
gvCart.DataBind()
End If
Next
End If
End Sub

View 2 Replies

Forms Data Controls :: How To Read Data From Stored Proceedure And Display To Gridview Using Object Datasource

Dec 8, 2010

I have an object datasource which is using Business object as a myconnection

The method i have defined under myconnection is

Publicstatic
DataTable getfn(String dtype,
String did,
String dprefix,
String dname)
{
datable table = new datatable(); then declared stored proceedure and defined parameters and assighned values

In the stored proceedure it has a query like select column1,coloumn2,coloumn3 As Call from table where
I need to take data from Call and display it to the gridview through object datasource .

View 1 Replies

Forms Data Controls :: Gridview Binding Without Datasource Controls?

Jan 27, 2011

I m new in asp.net. I want to use gridview with a custom business object.

Should i have property in my custom object.is there a way to access object fields.

View 4 Replies

Forms Data Controls :: Casting Gridview Datasource To Datatable?

Mar 9, 2011

i try casting the gridview datasource to datatable using the following code but the datatable always nothing.

Dim DT As New DataTable
DT = DirectCast(gv.DataSource, DataTable)

the gridview is bound using dataset at code behind without using sqldatasource.

i m trying to filter the gridview without geting the data from database, is there is another way to do this?

View 4 Replies

Forms Data Controls :: Return Dataset As Datasource For Gridview

Dec 5, 2010

I am trying to return a dataset. I must be doing something wrong. The returned dataset in this sample code indicates there is a datatable, Users, but there are no datarows. What am I doing wrong? This example is only using the rows.count, but of course I really need to use the whole datatable as the datasource for a gridview.

[Code]....

Public Function getmyds() As DataSet
Dim dsUser1 As DataSet = New DataSet()
Dim tbUser1 As DataTable = dsUser1.Tables.Add("Users")
tbUser1.Columns.Add("UserName")
tbUser1.Columns.Add("Days Remaining")
tbUser1.Columns.Add("UserAccountControl")
Dim rwDefaultUser1 As DataRow = tbUser1.NewRow()
rwDefaultUser1("UserName") = "John Smith"
rwDefaultUser1("Days remaining") = 100
rwDefaultUser1("userAccountControl") = "Enabled"
Return dsUser1
End Function

View 2 Replies

Forms Data Controls :: GridView Updating Having Datasource Datatable?

Jul 16, 2010

I am making shopping cart application.On Viewing Shopping Cart,when i try to update the quatity of product column it permit me to edit but wn i click update link.the gridview disappears wid all products.send me some code snippet in C# as i want only quantity column to be editable.I am using the following code:in Code behind File

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;

[code]...

View 4 Replies

Forms Data Controls :: Binding DropdownList In A GridView To A Datasource?

Sep 8, 2010

I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).

[Code]....

View 3 Replies

Forms Data Controls :: Gridview Datasource Canceled After Postback?

Aug 17, 2010

I have a GridView inside an UpdatePanel in which there is a TemplateField column. I need to save the value of this column every time a user changes it. The problem is that when the TextChanged event causes a postback, the GridView datasource is set to nothing. I've noticed that this happens every time there's a postback. Why?

Here is the code:

[CODE]

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Prova.aspx.vb" Inherits="Prova" %>

View 2 Replies

Forms Data Controls :: Gridview Datasource Is Null In Postback?

May 10, 2010

In asp I want to add row to my gridview when I read barcode. But when I want to add second row , gridview.datasource = null. So, my first row is removed from gridview in TxtBxBarcode_TextChanged event.

TxtBxBarcode and gridview are in the different update panels.

How can I prevent this "gridview.datasource is null when Postback" ?

View 4 Replies

Forms Data Controls :: Gridview Datasource Null When Sorting

Jan 11, 2010

I have 4 gridviews on a page that get databound with a datatable from sql. So I have created the sort/paging events for each. These were working fine. However now they do not work.

[Code]....

HTML Declaration:

[Code]....

View 3 Replies

Forms Data Controls :: GridView Datasource Is A IQueryable Is Not Displayed?

Aug 4, 2010

I have a query that joins two tables (in Linq) so I usethe result as an Iqueryable. I want the Query result to be displayed in a gridview, but for some reason I see nothing on the gridview.(I also tried without the join and just using the IQueryable result -and still nothing)

[Code]....

why is doesn't work, or link me to an examlple that is similar - (Also is there another way to use the result of a "join" not as IQueryable)

View 2 Replies

Forms Data Controls :: Looping Through Rows Of A Gridview Via The Datasource?

Mar 2, 2011

I have a Gridview that has Paging enabled, and I need to loop through all the rows of the data. Therefore, I assume I need to loop through the datasource instead of through the Gridview.

I change the datasource of my gridview at various times when running.

How can I get a DataView of the GridView's current DataSource, so that I can loop through it?

Something like:

Dim dv as DataView = DirectCast(GridView1.DataSource, DataView)

except that this comes back as Nothing, probably because a Datasource isn't a dataview.

View 3 Replies

Forms Data Controls :: What Kinds Of Objects Can Set For A GridView.DataSource

May 14, 2010

MyGridView.DataSource = <<<what kind of objects here?>>>

DataTable works. What else?

View 2 Replies

Forms Data Controls :: Paging And Sorting Gridview Without A Datasource?

Jan 14, 2011

I am trying to sort and page a dataset/table.

Problem: it will sort and paging correctly but when after change a page, it will not display the corrected sorted order.

Protected Sub PFTGridView_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles PFTGridView.PageIndexChanging
Dim PFTObj As New PFT
Dim PFTDST As New Data.DataSet

[Code]....

View 4 Replies

Forms Data Controls :: Use A CheckBoxList.SelectedItems As A Gridview Datasource?

Dec 30, 2010

Can a CheckBoxList.SelectedItems be used as a Gridview datasource?

View 8 Replies

Forms Data Controls :: DataKeyNames In GridView When Using Dictionary As DataSource?

Jul 10, 2010

how can I specify DataKeyNames for a GridView when using a dictionary as DataSource?

[Code]....

In this example I would like to use "cat", "dog", "llama" and "iguana" as DataKeys for the four rows.

View 2 Replies

Forms Data Controls :: Make The TextBox In The Gridview Template A Datasource?

Feb 6, 2010

I have a datagrid, with a template with a textbox in it. I am trying to add a "update" feature to my datagrid, writing my own code. Stuck on one thing though. I try to update the DataSet with this code:

[Code]....

But when running the code, an error message is showed saying that there where no changes to the GridView. This should probably be because the textbox in the gridview is never declared as a datasource for the gridview. How do i make the TextBox in the gridview template a datasource?

View 6 Replies

Forms Data Controls :: Putting Gridview Into Editmode Having Datasource=reader

Sep 14, 2010

I have a GV that is populated via a reader: Using reader As SqlDataReader = cmd.ExecuteReader() I have autogenerate edit button=T but it will not go into editmode. Must I create template to handle this?

View 4 Replies

Forms Data Controls :: Show Gridview Footer When Datasource Is Empty?

Mar 4, 2010

I have a gridview with insert new row controls in the footer binded to sql datasource. I want to show the footer when the datasource is empty. Although the empty data template is there but any other solution you fellows can tell me ?

View 7 Replies

Forms Data Controls :: GridView - Databind To A Collection Within A Custom Datasource?

Jun 14, 2010

I'm trying to databind my GridView to a custom datasource where one of it's members/fields is a collection.

Custom object Entry

public List<EntryHour> Hours { get; set; }

In practical terms, one row consists of some normal text fields which is easy to handle. However, the Hours field is the nut to crack.

How do I, in the GridView markup bind my textfields in question to the Hours field (which consists of 7 items allways)?

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved