Forms Data Controls :: Remove Either DataSource Or DataSourceID?
Nov 5, 2010How do we remove either DataSource or DataSourceID from FormView2?
Code behind reads:
[Code]....
How do we remove either DataSource or DataSourceID from FormView2?
Code behind reads:
[Code]....
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 RepliesWhen 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] .....
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]....
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]...
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.
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)
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 RepliesBut 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?
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?
I can filter on one of them (asp:DropDownList) like:
[Code]....
and I have this Calendar control:
[Code]....
How should I configure the Calendar control to filter the GridView1 on both DropDowList (ddlIP) and Calendar1?
how can i find the value in the field which contain "," and remove it in sql e.g:
the field is: 11,12,13
how can i find 12 and remove it becomes=> 11,13
if the field is 12,13,14==> 13,14
if the field is 9,10,11,12 ==> 9,10,11
if the field is 12 only ,then result is empty
I am using visualstudio C# with Sql server. I want to delete previous duplicate values if exists while inserting new values into the table.
View 2 RepliesI'm trying to remove extraneous characters like quotes, commas, etc from my dataset. I get the fact in the standard way of doing things in your code behind you simply go
string data = data.replace(",",""); or something like this. However, a datasource doesn't seem to give me that capability. What can I do to make it do this? I'm importing data from an excel sheet into a gridview. The commas are goofing up my view. I'd like to replace any commas in the dataset with spaces. Here is the code I have.
[Code]....
I have a field that may or may not contain comma.
if the field contain some word and separated by comma
how can i remove specific word in the field.
e.g. the field contain --> 11,12,13
how can i remove the number 12 and remain 11,13 in the field?
removing duplicate rows from datatable or (dataset) by columnd ID (unique). Below function is working but I would like to edit/adjust the remaing (former) duplicate row's value, not the ID value btw.
Example:
ID name sport
-------------------------------
356 John Football
357 Johny Hockey
357 Johny Hockey
358 mike Soccer
should be:
ID name sport
--------------------------------------------------------------
356 John Football
357 Johny newFoo Hockey
358 mike Soccer
Public Function RemoveDuplicateRows(ByVal dTable As DataTable, ByVal colName As String) As DataTable
Dim hTable As New Hashtable()
Dim duplicateList As New ArrayList()
For Each drow__1 As DataRow In dTable.Rows
If hTable.Contains(drow__1(colName)) Then
duplicateList.Add(drow__1)
Else
hTable.Add(drow__1(colName), String.Empty)
End If
Next
For Each dRow__2 As DataRow In duplicateList
dTable.Rows.Remove(dRow__2)
Next
Return dTable
End Function
how can i only display the name columne once in the repeater, when more than 1, then hidden the label
now my table are:
name col. age
mary 11
mary 16
Sam 18
now i would like to hidden the duplicate name as below:
name col age
mary 11
16
Sam 18
how can i manage the datatable to prevent duplicate name to bind to repeater.
[Code].....
and user3 duplicate more time as the table can i remove duplicate data
I have a Document name column with varbinary(max) type column in my table
first time when i upload document i am storing doc as a byte array
Dim fs As Stream = Me.fileupload1.PostedFile.InputStream
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(fs.Length)
in my application i have remove atttachmentDoc button, i want to remove uploaded doc from db
so when i pass like this to my storedprocedue
Dim obj As New cls1
Dim bData() As Byte = New Byte(0) {}
bData=nothing
With obj
Dim dt As DataTable = Read_Doc()
If dt.Rows.Count > 0 Then
If Not IsDBNull(dt.Rows(0)("Document")) Then
.Document = bData
.Document_extension = ""
.Remove_Attachment(Me.Selected_ID)
End If
End If
End With
i got error
dbAccess.executeQuery: Procedure or function 'SP_DML1' expects parameter '@Document', which was not supplied.
I have one requirement i.e i wanted to replace or remove all the special characters except alphanumeric in the column value
how to do ....
whats wrong with this SQL.
select a.Del_Date,a.Deliverables,
b.Cost_Code, c.UserName, c.Email
from mtblDeliverables a
join mtblContract_New b on a.Cost_Code
= b.Cost_Code
Join mtblUser c on b.Proj_Lead
= c.UserName
where a.Del_Date
= DateAdd(dAY, 10,
GetDate ());
This will show me all records which has a Del_Date = GetDate()+10 days.My data in the SQL is stored in datetime format.When i execute this, no records are shown. Is this because of the time part in the GetDate(). how to remove the timepart in the GetDate ().
I use an objectdatasource programmatically to use a parameterless method when SearchWord variable is empty and a Search method with one parameter when SearchWord is not empty, the event I use is objectdatasource selecting so that I can adjust parameters conveniently, I have a problem here: I can add a new parameter and set its value but I can't remove a previously added parameter from objectdatasource selectparameters and an error raises because of this, this is the selecting method:
[Code]....
Both adding and removing the search parameter takes place in this method while adding works removing the added one Not works.
I dont know if this is possible or not, but I have a column that I need to remove a bunch of exponent superscript references from a html field (and leave the rest). Does anyone know how to do this with SQL?
View 9 RepliesI have created a javascript to show hover colour and selected row in different colour in a gridview but when i select another row the previous row also still in the same selected row colour how to remove that.
View 3 RepliesI'm using a System.Web.UI.DataVisualization.Charting.Chart in VS 2008 / ASP.Net 3.5 with two y-axes. how to get rid of that horizontally gridlines of the second y-axis?
View 2 Replies