C# - Both DataSource And DataSourceID Are Defined On Listview, Remove One Source?

Jan 26, 2011

I'm getting the following error, ever since I moved my DataTable to a different function. Both DataSource and DataSourceID are defined on 'TestView'. Remove one definition.By all means if you have tips on style / standards, I welcome that as well, I am very new to aspx coding. Any idea what could be causing this? It wasn't happening before when it wasn't its own function. Is it a local variable problem?

Here's the code for the code that binds and is highlighted in the error:

testDAO tda = new testDAO();
DataTable testTable = new DataTable("TestView");
testTable = tda.GetTestTable();
TestView.DataSource = testTable;
TestView.DataBind();

Here's the code for the GetTestTable():

public DataTable GetTestTable()
{
DataTable testTable = new DataTable("TestView");[code]....

List view in aspx file:

<asp:ListView ID="TestView" runat="server">
<ItemTemplate>
<tr id="row" runat="server" class='<%# Container.DataItemIndex % 2 == 0 ? "row" : "altrow" %>'> [code]....

View 2 Replies


Similar Messages:

Data Controls :: Both DataSource And DataSourceID Are Defined On GridView1 - Remove One Definition

May 7, 2015

When i click for bug an aplication.

it's always show this a notification

{"Both DataSource and DataSourceID are defined on 'GridView1'.  Remove one definition."}

view on browser application

Line 33: Line 34: GridView1.DataSource = dtLine 35: GridView1.DataBind()Line 36: End SubLine 37:

This is an my vb code

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindGrid()
End If
End Sub
Private Sub BindGrid()

[Code] .....

View 1 Replies

Forms Data Controls :: DataSource And DataSourceID Are Defined On 'GridView1'. Remove One Definition?

Jul 23, 2010

I'm working on two gridviews , each one binded to an sqldatasource object,when I want to modify the 2nd gridview (DataSource=DataTable) an error fired !Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.

View 4 Replies

C# - Both DataSource And DataSourceID Are Defined Error Using With GridView

Jan 26, 2011

But it's different situation on gridview.

<asp:GridView ID="Grid_Goster" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource3" ForeColor="#333333" GridLines="None"
Height="144px" Width="316px">
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:SqlServerCstr %>"
SelectCommand="SELECT * FROM [AVUKAT]"></asp:SqlDataSource>

And i get error like this: Both DataSource and DataSourceID are defined on 'Grid_Goster'. Remove one definition. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'Grid_Goster'. Remove one definition. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using And in my .cs file there is code like this.

SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Grid_Goster.DataSource = dr;
Grid_Goster.Visible = true;

i think this code works correctly. How can i solve this DataSource and DataSourceID problem?

View 3 Replies

Forms Data Controls :: Both DataSource And DataSourceID Are Defined On 'DataList1'?

Nov 9, 2010

I receive the error (Both DataSource and DataSourceID are defined on 'DataList1'. Remove one definition) in the following code. Could anyone help me sort this out. I do not have anything named DatasourceID that I can find.
[code]...

View 2 Replies

Forms Data Controls :: Remove Either DataSource Or DataSourceID?

Nov 5, 2010

How do we remove either DataSource or DataSourceID from FormView2?

Code behind reads:

[Code]....

View 3 Replies

Data Controls :: ListView Already Bind With DatasourceID - Cannot Bind It With Datasource

Oct 13, 2013

I have connected listview by using datasourceid that means by using "sqldatasource1" now i want to change value of listview at run time according to search so for that i am using datasource at codebehind. but it give an error 

"listview have already bind with datasourceid you can not bind it with datasource"

what should i do for solving my requirement.

View 1 Replies

DataSource Controls :: ListView + LinqDataSource Data Source And Load The Listview On Search Button Click Action?

Mar 22, 2010

I am trying to populate the ListView using LinqDataSource data source but the issue I am having is.I need to load the listview on Search button click action.

IN the page_load I kept like this:
===========================================
LinqDS.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDS_Selecting);

protected void LinqDS_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
e.Result = ObjectDS;
}
=============================================
This works fine but this happens on page load,i want this binding to happen on button click?is there a way to do this?

View 2 Replies

Forms Data Controls :: Bind ListView DataSourceID To ObjectDataSource With Button_Click

Jan 12, 2011

I successfully bind ListView DataSourceID to ObjectDataSource but it binds only initially on Page_Load event.
When I want to bind another data through a Button_Click event, the new data doesn't bind.

aspx code:

[Code]....

Codebehind:

[Code]....

On Page_Load, I get result:

A1
<hr />
T1
A2
<hr />
T2
A3
<hr />
T3

When I Button1_Click, nothing happens, no error, no any more results and _airLineData is 53 records, not 3 records (A1T1 to A3T3) I want the binding to be with DataSourceID to ObjectDataSource (not through DataSource property and control.DataBind() method)

View 6 Replies

AJAX :: How To Update Reorderlist When Using DataSource Instead Of DataSourceID

Jan 27, 2010

Instead of using DataSourceID I have a DataSource built up in codebehind that I bind to the reorderlist. I have set "PostBackOnReorder=True" but how do I update the database on that postback? How do I collect the new order and then save it to the database?

View 1 Replies

Get The DatasourceID Of The Datasource That's Firing The OnSelecting Event?

Mar 11, 2011

I have a couple different sqldatasources on an asp.net page that all fire the same onSelecting Event Handler. The reason for this is because the same code in the event handler can be applied to all datasources (which essentially generates filters in the queries dynamically). However, now I have another datasource that can still use most of the code, but needs to be handled slightly differenty. I could do this very easily if I could reference the datasource's ID that is firing the event (which I've tried), but this doesn't seem to be possible. Here is what I initially attempted to do:

protected void sdsTable_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
SqlDataSource sds = sender as SqlDataSource;
string dsID = sds == null ? "" : sds.ID;
if (dsID == "aDataSourceID")
{
//do this
}
else
{
//do that
}
//more code
}

This didn't work because sender is of type SqlDataSourceView and trying to cast sender as SqlDataSource returns null. So, I changed it to SqlDataSourceView:

protected void sdsTable_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
SqlDataSourceView sds = sender as SqlDataSourceView;
string dsID = sds == null ? "" : sds.Name; //Tried Name property because ID isn't available
if (dsID == "aDataSourceID")
{
//do this
}
else
{
//do that
}
//more code
}

But this still doesn't work. SqlDataSourceView doesn't seem to have a property available that gives the datasourceID of the datasource that is currently firing the event. There is a SqlDataSourceView.Name property, but this is something different. Does anyone know if it is possible to get the ID of the DataSource firing the Selecting event when that event is being handled? If so, can you provide an example on how to do this?

View 1 Replies

C# - Remove A Defined Part Of A String?

Mar 15, 2011

I have this string: "NT-DOM-NVMTA" How can I delete the first part: "NT-DOM-NV" To have this as result: "MTA"

View 6 Replies

C# - Bind The Datasource Of A Nested ListView To The Parent's ListView Datasource?

Dec 13, 2010

I have triple-nested ListView controls on my asp.net page, each nested within another. I use the OnItemDataBound event in the 1st ListView to set the DataSource of the 2nd level ListView. The 3rd ListView is contained in the of the 2nd ListView. I want to assign the same DataSource to both the 2nd and 3rd level ListView datasource controls, but I cannot figure out how to access the 3rd level ListView in order to do that.

[Code]....

The level1_ItemDataBound method finds the level2 control, casts it as a ListView, sets its DataSource and executes the DataBind. At this point I'm stuck trying to get Level3.DataSource to be set to the same as Level2.DataSource.

View 1 Replies

C# - Accessing Current Item From ListView Data Source?

Jan 23, 2011

I figured this wouldn't be too difficult to do, but I can't seem to figure out how to do it. Is there a way to easily access the current item from a ListView data source? For instance, you can easily evaluate the current item's properties using Eval("propertyName"), but is there a way to access the object itself?

And if this isn't possible, what I ultimately want to do is get the Type of the object.

View 1 Replies

Forms Data Controls :: Cannot Remove Listview Item

Aug 11, 2010

I Use listView and flow configure and connect to database whit wizard.

in Item Template View, i cannot remove items, when reomve it, after 2 seconds, An item that was deleted is shown again!

View 6 Replies

AJAX :: How To Remove (hide) Selected Row In ListView Control

May 7, 2015

I need to remove the selected row in listview without affect the database in button click event.

View 1 Replies

Forms Data Controls :: How To Remove Row (Client Side) From ListView

Dec 11, 2010

I have 2 pages. Retrieving selected values with session from my first page then

listing them in my second page. How can i remove clicked row from listed products? (NOT from My Northwind Database.)

View 2 Replies

Forms Data Controls :: Find Item From ListView And Remove It?

Jan 30, 2010

I have a list view with couple rows, which has a delete button for each row.

Now once the delete is performed and it's a success, I want to remove that item from the ListView

[Code]....

View 4 Replies

DataSource Controls :: 'SqlConnection' Is Not Defined In The Behind Code?

Oct 29, 2010

'SqlConnection' is not defined in the behind code as follows:

Source Error:

[Code]...

Source File: I:WebsitesCMPHostFox BackupDefault.aspx.vb Line: 24

Snippet reads as follows:

[Code]...

View 5 Replies

DataSource Controls :: Way To Create User Defined Type

Feb 25, 2010

I am trying to create a type of table on sql 2008. The following sql fails saying Incorrect syntax near the keyword 'AS'. what i am doing wrong as this looks fine to me.

View 1 Replies

DataSource Controls :: Call Sql User Defined Function?

Feb 13, 2010

i have created a function to call username to pass user id as pararameter,

how to call userdefined function in asp.net

here is my function in sql

CREATE FUNCTION getusername
( @userid bigint )
RETURNS table
AS
RETURN (
SELECT login_id
FROM mst_useraccount
WHERE user_key =@userid
)
go

View 3 Replies

DataSource Controls :: Type 'System.Data.OleDb.OleDbCommand' Is Not Defined?

May 7, 2010

i am trying to export a table from access database to excel sheet but i am facing error saying Type 'System.Data.OleDb.OleDbCommand' is not defined.

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsUSERDesktopD0605data.accdb")
AccessConn.Open()
'New sheet in Workbook
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Excel 8.0;DATABASE=C:Documents and SettingsUSERDesktopD0605data1.xlsx;HDR=NO;].[Sheet1] from [Table1]", AccessConn)
AccessCommand.ExecuteNonQuery()
AccessConn.Close()
End Sub
End Class

View 5 Replies

DataSource Controls :: The Type 'System.Data.Linq.DataContext' Is Defined In An Assembly That Is Not Referenced?

May 28, 2010

I have a strange problem. I am adding a LinqDatasource object, and set the context:

[Code]....

Then I get this error:The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

On web.config I already have this:

<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?

View 12 Replies

Forms Data Controls :: Use Function As ListView Data Source?

Aug 15, 2010

Below is my Classe structure to do linq query .I have a List View and I want to use "Get_PostsByType" funtion as it's datasource. So I use

Dim DataSet1 As New Reports.PostListModel
ListView1.Datasource=DataSet1.Get_PostsByType("SampleName")
ListView1.Databind()

but it's not working. and I encounter this Error

Unable to cast object of type 'System.Data.Objects.ObjectQuery`1[Reports.PostListModel]' to type 'System.Linq.IQueryable`1[Reports.PostListModel]'.

Note: I dn't want to use Object Datasource Since I need to customize Funtion input parameter

[Code]....

View 1 Replies

DataSource Controls :: ObjectDataSoruce And "No Parameterless Constructor Defined For This Object."

Jan 7, 2010

I have impelemented my own mvc pattern to my website , when I add desired type for my ObjectDataSource pointing to the controller class although GridView refreshes schema in designer just fine I get an error in runtime saying : "No parameterless constructor defined for this object." which is self explaining but I wonder why does it happening because I've used this pattern once and didn't have that issue , here is the bit of code that is causing this issue , what to do to keep my mvc and make it work :

[Code]....

View 1 Replies







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