Modified Sqldatasource.filterExpression While Sqldatasouce.selecting Event

Apr 25, 2008

I facing a problem when i want to modified the sqldatasource.filterExpression while trigger sqldatasource.selecting event.   1 Protected Sub SqlDsProduct_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
2 Dim SqlDsProduct As SqlDataSource = CType(CompleteGridView1.DetailRows(0).FindControl("SqlDsProduct"), SqlDataSource)
3 SqlDsProduct.FilterExpression = Session("filter") ' filter i add up after user press search button
4 End subActually i'm using the CompleteGridview, which i downloaded from the web. the "SqlDsProduct" i reffering to is inside the CompleteGridView1. I'm using complet grid view because i want the hierarchy look for the gridview. So please help me how i gonna change the filter expression of the 2nd sqldatasource inside detailsTemplate of the completeGridview. Thank you. best regardvince
 

View 6 Replies


ADVERTISEMENT

How To Access Underlaying DataView Of SQLDataSouce In It's Selected Event

Jun 30, 2006

I need access to the underlying DataView associated with a declaratively defined SQLDataSource. Ideally, I need this access in the SQLDataSource's Selected event. I know that I can use the SQLDataSouce.Select() method to return the underlying DataView object. But, there is a GridView control bound to the datasource so I don't want to explicity call Select() since it will end up being called again implicity by the gridview itself. I have seen that this can be done with an ObjectDataSouce as follows:
void odsDataSouce_Selected(object sender, ObjectDataSourceStatusEventArgs e) {  DataView oDV = (DataView)e.ReturnValue;}
Is there any way to accomplish the same thing with a SQLDataSouce?  It seems hard to believe that the query results are not exposed to the Selected event.
Thanks!
 
 

View 4 Replies View Related

SQLDatasource Filterexpression

Feb 5, 2007

Hi
on my page: two sqldatasources one has the sqlexperession:
SELECT DISTINCT [Skil] FROM [UsersView]UNIONSELECT 'Alles'
the other one :
SELECT [UserName], [Afdeling], [Skil], [RoepNaam] FROM [UsersView]
the first source is bound to a dropdown list. witch I want to use for filtering.
the second to a gridview.
the code for the dropdownlist selectedindexchanged is:protected void SkillDDL_SelectedIndexChanged(object sender, EventArgs e)
{
if (SkillDDL.SelectedValue.ToString() == "Alles")
{
SqlDataSource3.FilterExpression = "";
}
else
{
SqlDataSource3.FilterExpression = "Skil = '" + SkillDDL.SelectedValue + "'";
}
}
 The strange thing is that initially 'Alles' is selected in the dropdown list and I see all the records. then I select an other value in the dropdownlist. and I get the filtered records, like I would expect.
then when I select 'Alles' again I keep my last selected records in view. I would expect that the filter is now an empty string and I would get all the records again. what do I do wrong?
thanks
 
Rob Warning

View 2 Replies View Related

Issue With SQLDataSource And FilterExpression

Feb 21, 2007

I'm not sure exactly how the FilterExpression works. I have a sqldatasource, stored procedure, and GridView. My stored procedure basicly a select statement to populate my gridview, it included the fields I want to filter on. In my codebehind file I build a WHERE Clause based on the entries a user makes. Then I add the my FilterExpr variable to the SqlDataSource1.FilterExpression = FilterExpr. My SqlDataSource has a number of control parameters that match the textboxes a users enters into.
My question, I guess is does my stored procedure need the variables matching my controlparameters for my sqldatasource? Or how does this work? My GridView is returning all rows no matter what I enter into the filter textboxes (first, last, etc...)
MY SQLSDATASOURCE <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="ClientSearch" SelectCommandType="StoredProcedure">
<FilterParameters>
<asp:ControlParameter ControlID="SearchLastName" Name="LastName" PropertyName="Text" ConvertEmptyStringToNull="true" />
<asp:ControlParameter ControlID="SearchFirstName" Name="FirstName" PropertyName="Text" ConvertEmptyStringToNull="true" />
<asp:ControlParameter ControlID="SearchEmail" Name="Email" PropertyName="Text" ConvertEmptyStringToNull="true" />
<asp:ControlParameter ControlID="SearchAddress" Name="Address" PropertyName="Text" ConvertEmptyStringToNull="true" />
<asp:ControlParameter ControlID="SearchComment" Name="Comment" PropertyName="Text" ConvertEmptyStringToNull="true" />
</FilterParameters>
</asp:SqlDataSource>MY CODEBEHIND        Dim FilterExpr As String        If SearchLastName.Text = "" And _            SearchFirstName.Text = "" And _            SearchEmail.Text = "" And _            SearchComment.Text = "" And _            SearchAddress.Text = "" Then            lblMessage.Text = "You didn't enter any search parameters. Please try Again."            Me.GridViewSearch.DataSourceID = ""            Exit Sub        Else            Me.GridViewSearch.DataSourceID = "SqlDataSource1"        End If        FilterExpr = ""        If SearchLastName.Text <> "" Then            FilterExpr = FilterExpr & "LastName Like '" & _            SearchLastName.Text & "%" & "' AND "        End If        If SearchFirstName.Text <> "" Then            FilterExpr = FilterExpr & "FirstName Like '" & _            SearchFirstName.Text & "%" & "' AND "        End If        If SearchEmail.Text <> "" Then            FilterExpr = FilterExpr & " Like '" & _             SearchEmail.Text & "%" & "' AND "        End If        If SearchComment.Text <> "" Then            FilterExpr = FilterExpr & "[Comments] Like '" & "%" & _             SearchComment.Text & "%" & "' AND "        End If        If SearchAddress.Text <> "" Then            FilterExpr = FilterExpr & "[Address] Like '" & "%" & _             SearchAddress.Text & "%" & "' AND "        End If        If Right(FilterExpr, 4) = "AND " Then            FilterExpr = Left(FilterExpr, Len(FilterExpr) - 4)        End If        Try            Me.SqlDataSource1.FilterExpression = FilterExpr            Me.SqlDataSource1.DataBind()            Me.GridViewSearch.DataBind()            Me.lblMessage.Text = Me.SqlDataSource1.FilterExpression        Catch objException As SqlException            Dim objError As SqlError            For Each objError In objException.Errors                Response.Write(objError.Message)            Next        End Try    End Sub 
MY SPROCGO
ALTER PROCEDURE [dbo].[ClientSearch]

AS
SELECT C.ClientID, C.FirstName, C.LastName, A.Address,
C.Comments, C.EMail
FROM tblClient C INNER JOIN
tblClientAddresses A ON C.ClientID = A.ClientID 

View 1 Replies View Related

FilterExpression And The SQLDataSource Control

Feb 16, 2008

I have a SQLDatasource control on a web page. It is the datasource for a gridview control.I want the gridview to show all jones if the FirstName textbox is left blank or empty. Right now I have to put a % in the FirstName textbox to get what I want. If I make the FirstNameTextBox empty or remove the % from the FirstNameTextbox it returns all the names in the database no matter what the last name is.How do I get it to work without having to use the % in the FirstName Textbox? THANKS!FilterExpression="LastName LIKE '%{0}%' and FirstName LIKE '%{1}%'"><FilterParameters>            <asp:ControlParameter ControlID="LastNameTextBox" Name="LastName" PropertyName="Text" DefaultValue="" />            <asp:ControlParameter ControlID="FirstNameTextBox" Name="FirstName" PropertyName="Text" DefaultValue="" /></FilterParameters>
Last Name: Jones___________First Name: %_____________FILTERBUTTON
GridviewLast Name      First NameBob                JonesBill                 Jones
 

View 6 Replies View Related

Sqldatasource.filterexpression - Different Use For/of - Populate A Dataset

Aug 31, 2007

How does one programmatically retrieve the results from a sqldatasource that has had a filterexpression applied to it?
Let me elaborate, here is my code:
SqlDataSource1.FilterExpression = "MenuType = 'myfilteredvalue'"
Dim _dv As DataView = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.DataView)
_dv.Table.TableName = "Menu" Dim ds As New DataSet("Menus") ds.Tables.Add(_dv.Table.Copy()) 'Add relation: ParentID under MenuID
Dim relation As New DataRelation("ParentChild", ds.Tables!Menu.Columns!MenuID, ds.Tables!Menu.Columns!ParentID, True) relation.Nested = True
ds.Relations.Add(relation)
What I'm doing is, I have a sqlDataSource that pulls all the data from my DB. With this data in the sqlDataSourceSource, I want to then populate an XMLDatasource (via a dataset) with only the records I need, i.e. the filter. However, after I apply my filter above, the sqlDataSoruce still contains all the records. I thought maybe if I did a sqlDataSource.Bind() after my SqlDataSource.FilterExpression, but that didn't do anything either.In laymans terms:I want to say something like: dataset = sqldatasource.filter(my filter expression). 

View 2 Replies View Related

SqlDataSource.FilterExpression: Can't Get It Work With Dates?

Mar 18, 2008

 I am using the FilterExpression of an SqlDataSource object to filter the rows of a gridview.  It works with searching text values but I cannot for the life of me figure out to get it to work with dates.   The following is what I do for character searches: SomeDataSource.FilterExpression = fieldToSearch + " LIKE '%" + SearchTextBox.Text + "%'";  This works.  However when I try to search for dates using the following it doesn't work (startDate and endDate are DateTime objects):SomeDataSource.FilterExpression = fieldToSearch + " BETWEEN #" + startDate.ToString("yyyy-MM-dd") + "# AND #" + endDate.ToString("yyyy-MM-dd") + "#";// or
SomeDataSource.FilterExpression = fieldToSearch + " = #" + startDate.ToString("yyyy-MM-dd") + "#";// or
SomeDataSource.FilterExpression = fieldToSearch + " = #'" + startDate.ToString("MM/dd/yyyy HH:mm:ss") + "'#";  

View 6 Replies View Related

Sqldatasource Filterexpression In Code Mode

Apr 14, 2008

I have wrote some codes as follows: 
        Dim sqldatasource3 As New SqlDataSource        sqldatasource3.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("aspnetConnectionString").ConnectionString        sqldatasource3.SelectCommand = "select stepno,steppersontype,stepname,steptype,fchoice,fforward,schoice,sforward from flow "        sqldatasource3.FilterExpression = "stepname = '" & GridView1.SelectedRow.Cells(4).Text.Trim & "'"        sqldatasource3.DataSourceMode = SqlDataSourceMode.DataSet        Dim dv As DataView = sqldatasource3.Select(DataSourceSelectArguments.Empty())        dv.RowFilter = "stepname = '" & GridView1.SelectedRow.Cells(4).Text.Trim & "'"
but i found the filterexpression didn't work. No matter what value GridView1.SelectedRow.Cells(4).Text.Trim be,sqldatasource always return the whole dataset.I wanna know where these code are wrong? Can anyone help?

View 1 Replies View Related

Need Some Help On SELECTING Event

Apr 21, 2008

hello all,
i have a nested gridview. how do i add a SELECTING event for this datasource for my inner gridview? because i need to increase the commandtimeout. thnx.
   private SqlDataSource ChildDataSource(string strCustno)    {        string strQRY = "Select ...";        SqlDataSource dsTemp = new SqlDataSource();                dsTemp.ConnectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString  ;                        dsTemp.SelectCommand = strQRY;                return dsTemp;    }

View 1 Replies View Related

Using SQLDataSource OnSelecting Event

Jul 21, 2006

I have two SQLDataSource controls on my page that are dynamically fed an SQL SELECT statement. I was thinking that the best way to do this was to give it the select statement that it needs inside the OnSelecting event. Here is the revelent code.

&lt;asp:SqlDataSource OnSelecting=&quot;GetData_Selecting&quot; ID=&quot;DS1&quot; ConnectionString=&quot;&lt;%$ ConnectionStrings:MyConnectionString %&gt;&quot; ProviderName=&quot;&lt;%$ ConnectionStrings:MyConnectionString.ProviderName %&gt;&quot; runat=&quot;server&quot; SelectCommand=&quot;&quot; /&gt;
&lt;asp:SqlDataSource OnSelecting=&quot;GetData_Selecting&quot; ID=&quot;DS2&quot; ConnectionString=&quot;&lt;%$ ConnectionStrings:MyConnectionString %&gt;&quot; ProviderName=&quot;&lt;%$ ConnectionStrings:MyConnectionString.ProviderName %&gt;&quot; runat=&quot;server&quot; SelectCommand=&quot;&quot; /&gt;



protected void GetData_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
System.Diagnostics.Debug.WriteLine(&quot;Getting Data...&quot;);

switch ((sender as SqlDataSource).ID)
{
case &quot;DS1&quot;:
if (Checkbox1.Checked)
{
e.Command.CommandText = &quot;SELECT * FROM table1 WHERE &quot; + BuildQuery(getMylarColumns(), SearchBox.Text);
DS1Panel.Visible = true;
}
break;

case &quot;DS2&quot;:
if (Checkbox2.Checked)
{
e.Command.CommandText = &quot;SELECT * FROM table2 WHERE &quot; + BuildQuery(getFlatFileColumns(), SearchBox.Text);
DS2Panel.Visible = true;
}
break;
}


The problem with this is that the GetData_Selecting method is never executed and thus when I try to execute the query the page PostBacks and nothing happens. Putting equivalent code in the Page_Load method works fine, however I believe having the code execute on each PostBack is the reason I'm having another problem sorting the data in the DataGrids these controls are bound to.

Why is the function never being executed? Is this the ideal way to handle the inclusion of the query in the SQLDataSource?

View 5 Replies View Related

Using The OnSelected Event Of SqlDataSource

May 18, 2008

Hello,
on my site I have a sqldataSource and a listview working together. But now after selecting data from my database and before binding data to the listview i want to change the data. For example: I select an image filename and i want to check if the file exists, and if it not exists i want to change this filename. How can I do that. My Idea was to use the OnSelected Event of the datasource, but i don't know how to acces the selected data ...
 I hope someone can help me
 Party-Pansen

View 10 Replies View Related

SqlDataSource Inserting Event Error

Apr 12, 2007

Greetings,
When using Inserting event of SqlDataSource ASP.NET gives me an error when I reference InsertParameter by Name
An SqlParameter with ParameterName 'CreatedByEmployeeId' is not contained by this SqlParameterCollection.
However, when I reference parameter by index everything works.
Is this a bug or I'm doing something wrong?
Here's the code:
<asp:SqlDataSource ID="dsRole" runat="server" ConnectionString="<%$ ConnectionStrings:SecurityConnectionString %>" DeleteCommand="spDeleteRole" InsertCommand="spAddRole" SelectCommand="spGetRole" UpdateCommand="spUpdateRole" DeleteCommandType="StoredProcedure" InsertCommandType="StoredProcedure" SelectCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="UpdatedByEmployeeId" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="CreatedByEmployeeId" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="RoleId" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
When using parameter name, I get an error:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters("CreatedByEmployeeId").Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub
When using index instead of name, there's no problem:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters(2).Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub

View 2 Replies View Related

Should SqlDataSource Selected Event Always Fire?

May 2, 2007

Hi
 In the page load of my webpage I call a databind for a gridview.
It generally calls this event handler :
protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
 
However sometimes (seemingly randomly) it doesn't.
Any ideas?
Thanks

 
protected void Page_Load(object sender, EventArgs e)
{
...
if (searchText != "")
    SqlDataSource1.SelectParameters["search"].DefaultValue = searchText;
else{
SqlDataSource1.SelectParameters["search"].DefaultValue = "";
GridView1.DataBind();
}

View 2 Replies View Related

Sqldatasource Onselected Event Not Firing

Oct 3, 2007

Hi All - I've got a simple gridview/sqldatasource page, but the sqldatasource_onSelected event isn't firing.
heres the parameters <SelectParameters>
<asp:QueryStringParameter Name="LicenceID" QueryStringField="LicenceID" Type="string" />
<asp:QueryStringParameter Name="SiteID" QueryStringField="SamplingSiteID" Type="string" />
</SelectParameters>

either or both parameters may be null (ie. not in querystring )  .
If only one of the selectparameters is null, and I remove it, the event fires!!!
The parameters in the stored proc are optional(ie. default = NULL) and it works fine if I test it in SQL .
Whats going on? If there's some error happening, why no error raised? if there are no records returned, the onselected event should still fire shouldn't it?
Geoff 
 
 
 
 
 

View 2 Replies View Related

Sqldatasource Selected Event Not Firing?

Oct 4, 2007

Using Sql server 2005, SQLdatasource, I need to display total rows count.  But the selected event is not fired?  Am I mssing something or doing something wrong? Please comment.  thanks
Code<asp:SqlDataSource ID="DataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AuditToolConnection%>"
ProviderName="System.Data.SqlClient"SelectCommandType="StoredProcedure"
SelectCommand="usp_Dashboard_GetAll" >
 --------------------------------
public in recordCount = 0;protected void DataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
recordCount = e.AffectedRows;
lblCount.Text += recordCount.ToString();
}

View 2 Replies View Related

SqlDataSource OnSelected Event Not Firing

Nov 20, 2007

Hi,
 I have a SqlDataSource whose select statement uses parameters from the selected row on a gridview on the page. So when a row is selected in the gridview, I want the SqlDataSource to do a select using the new parameters, and then I want to inspect the number of rows returned. If 0, I want to set a FormView to insert mode, if >0 I want to set the FormView to edit mode.
The "SqlDataSource2_Selected" sub never fires, so I cannot retrieve the number of rows returned. How can I deal with this? I would like the SqlDataSource to execute a Select each time the Gridview selected row changes. What could prevent "OnSelected" from firing?
 I do have "OnSelected="SqlDataSource2_Selected" within the SqlDataSource tag.
 Thanks in advance for any help with this.

View 7 Replies View Related

SqlDataSource Inserted Event Appears To Execute Twice!

Nov 9, 2007

Hello
I have a piece of VB.NET code that generates an email on the SqlDataSource Inserted event.  It appears to be executing twice because it is sending two emails.  If I place the code on any other event, it just sends the one email.  Does any have a suggestion on how to handle this?
Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted 
Dim MailServerName As String = "alvexch01"Dim Message As MailMessage = New MailMessage
Message.From = New MailAddress("sender@email.com")Message.To.Add("receiver@email.com")
Message.Subject = "Near Miss"
Message.Body = "Test"
Message.IsBodyHtml = True
Message.Priority = MailPriority.NormalDim MailClient As SmtpClient = New SmtpClient
MailClient.Host = MailServerName
MailClient.Send(Message)
Message.IsBodyHtml = True
Message.Dispose()
End Sub

View 1 Replies View Related

Set Sqldatasource Parameter Value At Onclick Event Of Button

May 14, 2008

i have formview and gridview in onepage, and formview bind to one sqldatasource, which have select commandtype is storedprocedure,
now stored procedure have one optional parameter and select command.
 in gridview i have one button,now i want when user click on tha button that record's value comes in formview and its mode is edit.
now for that i have to pass that stored procedures parameter value,to stored procedure now how can i add the parameter value when the onclick event of gridview button is fire.
 thanks

View 3 Replies View Related

How To Handle Filtering Event In A Sqldatasource Control

Jan 19, 2006

Hello,
I have a sqldatasource  and a textcontrol on a webform, i assign programmatically  the text of the textcontrol to the filterexpression. 
If the filterexpression is incorrect the page hang, how can i handle this event
Thanks
JPR

View 1 Replies View Related

Deleted Event On Sqldatasource And Output Parameters... Always NULL!!

Apr 18, 2007

I have an event:
Private Sub SqlDataSourceIncome_Deleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSourceIncome.Deleted
Dim command As SqlClient.SqlCommand
command = e.Command
If command.Parameters("@nReturnCode").Value <> 0 Then
    DROPDEAD()
End If
That  fires from:
<DeleteParameters>
<asp:Parameter Name="nDeletebyId" Type="Int64" />
<asp:Parameter Name="nOtherId" Type="Int64" />
<asp:Parameter Direction="Output" Name="nReturnCode" Type="Int64" />
<asp:Parameter Direction="Output" Name="nReturnId" Type="Int64" />
</DeleteParameters>
End Sub
 
When I:
GridViewIncome.DeleteRow(GridViewIncome.SelectedRow.RowIndex)
But nReturnCode is ALWAYS NULL... I even did a stored procedure that just:
ALTER PROCEDURE [dbo].[sp_nDeletebyId]
 @nReturnCode bigint output,
@nReturnId bigint output AS
SET @nReturnCode = 0
SET @nReturnId = 0
And STILL got nothing but the NULLS... the insert & update stuff works fine, with identical code... it's just the DELETED event that I can't seem to knock.  Has anyone seen this before?  The above sample stored proc did return 0 when executed one the server...
and, BTW, the row is deleted!
 
Chip Kigar
 

View 2 Replies View Related

Programmatically Loop Through Sqldatasource - Which Event To Place It In...to Get The Right Order....

Mar 7, 2008

Hello,  I want to loop through the first 10 records that are showing in a gridview with several pages that is populated by a sqldatasource.  I can loop through the sqldatasource and get the list of values, but I'm doing something wrong because the 10 records it prints out are not the same 10 records the user sees in the gridview...They can click a search button which changes the sort, and they can click on the column headings to change the sort order.
Where's the best place to put the looping code?  I need the result to be the same as what the users sees. 
  1        Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.Sorted2            Dim i As Integer = -13            Dim sTest As String = ""4            Dim vwExpensiveItems As Data.DataView = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), Data.DataView)5    6            'Loop through each record7            i = -18            For Each rowProduct As Data.DataRowView In vwExpensiveItems9                i = i + 110               'Output the name and price11               If i > 9 Then12                   Exit For13               End If14               sTest = rowProduct("employeeid")15               Response.Write("RowSorting " & i.ToString & " [" & sTest & "]<br>")16           Next17       End Sub18    

View 3 Replies View Related

Selecting Dates From Database With SqlDataSource

Sep 13, 2006

HiI have a table in my database called 'tblUsers'It contains usernames and a few columns of data.One of them in 'birthday'it is in the format dd/mm (ie 28/04 is 28th of april)it is always 5 characters longIts data type is char in my db.Now I try this<asp:SqlDataSource ID="SqlDataSource8" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetConnectionString %>"            SelectCommand="SELECT DisplayName FROM [tblUsers] WHERE ([Birthday] = @ShortDate)">            <SelectParameters>                <asp:ControlParameter ControlID="Calendar1" Name="ShortDate" PropertyName="SelectedDate" Type="string" />            </SelectParameters>        </asp:SqlDataSource>where the selected date from a calendar control is used.Now it works when the table has a Date column which is off type DateTime but how would I modify it to work like I want?Thanks!

View 3 Replies View Related

To Catch The Event When There Is Empty Dataset As A Result Of A Query In Sqldatasource

Aug 1, 2007

hi,
i want to execute a finctionX() based on the returned resultset of SQLDataSource. For example, if the SELECT command returns nothing based on a specific search criteria then I want to execute functionX(). Currently, I have a string that displays "No Result" in the GridView in such case.
How to catch the  resultset of SQLDataSource?
-nero

View 1 Replies View Related

SqlDataSource Selecting/Selected Events Not Firing

Nov 21, 2006

Hi,I have a SqlDataSource and am trying to establish if it returns rows using the selected event e.AffectedRows statement. Unfortunately the selected event does not fire. I am using a stored procedure with 2 parameters:applicantID - Int32 - Parameter source from control label textissueStatus - Int16 - Parameter source 'None' default value = 1 When i test it during configuration it returns 1 row as expected. I am manually running the DataSource using ds.DataBind(); after a button click. Anyone know why its not firing the event?Thanks 

View 2 Replies View Related

SqlDataSource Events Selecting And Selected Not Work

Dec 28, 2005

When I handle a event for selecting to change the value of a parameter it does not use the new value and the selected event is never called. What am I doing wrong?
 
protected void OptionListSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
string productID = Request.QueryString["p"].ToString();
SqlDataSourceView Source = (SqlDataSourceView)sender;
Source.SelectParameters["ProductID"].DefaultValue=productID;

}
protected void OptionListSource_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
SqlDataSourceView Source = (SqlDataSourceView)sender;
}

View 1 Replies View Related

SqlDataSouce.SelectCommand

Feb 3, 2006

How do you programmatically change the SQL select statement for the SelectCommand in a SqlDataSource?For instance, if I had two buttons on a page, and for one button, I'd like it to change the select command to be "SELECT * FROM authors WHERE au_id > 100". Then for the second button, I'd like it to show "SELECT * FROM authors WHERE au_lname like S%".Anybody know the code to do this? I was trying to type the code, but the intellisense didn't give me any options to pick from after I typed SqlDataSouce1.SelectCommand.

View 3 Replies View Related

How To Use Update Command At Sqldatasouce

Sep 24, 2007

 hello all..,i have problem in update sqldatasource,  my code like that:me.sqldatasource.updateparameter(index).defaultvalue=valueme.sqldatasource.update()it can not update data, why?but if i use insert or delete like:me.sqldatasource.insertparameter(index).defaultvalue=valueme.sqldatasource.insert()me.sqldatasource.deleteparameter(index).defaultvalue=valueme.sqldatasource.delete()it can work for insert and delete data...can anyone give me update command code in sqldatasouce? plsss...thx...  

View 11 Replies View Related

Looping Through SQLDataSouce In A Function

Feb 17, 2006

Hi All,
Thanks for looking at the post. Here is what I am trying to do:
Lets say I have dragged and dropped a new SqlDataSource onto the page and called it SQLDataSource2
Now, in a function that happens afterload:
Protected Sub Partners_afterLoad(ByVal sender As Object, ByVal e As System.EventArgs)
I want to be able to loop through that SQLDataSource2, and pull a value to compare.
In classic ASP it would be something like:
'Move to the first recordSQLDatasource.MoveFirst'Loop through RecordsetWhile Not SQLDataSource2.Eof'Do compare of the Field MyValueIf SQLDataSource2("MyValue")=27 Then Reponse.Write "Hit on # 27"'Move to Next RecordSQLDatasource.MoveNext'End the loopWend
My questions are as follows:
1) Do I need to define the Datasource in the function, or can I use the one that VWD2005 helped me to define.
2) How can I loop throught that Datasource (Recordset) in a function.
Any and all help appreciated--Code examples will make me your best friend.
 
 

View 7 Replies View Related

How To Update When Dynamic Select SQL By Using SQLDatasouce In .net 2.0?

Apr 5, 2007

In Dot net 2.0 we change using SQLDataSource to Conect with SQLDB.
Now for My case ,the Select SQL is dynamic when differnece user and parameters to the page, So if I want to Update the data input by user,then I must give Update/insert/delelte SQL to SQLDatasource's InsertCommand /UpdateCommand/DeleteCommand . 
How to Generate the Insert/update/delete command for the SQLDataSource ? as in dot net 1.1 can use SQLCommandBuilder to generate it,but SQLCommandBuilder  just support DataAdeptor not for SQLDataSource, Could any body know how to do it when the SelectCommand is dynamic and need to update data back to DB after edit?
 thanks a lot.

View 4 Replies View Related

Filterexpression In ASP 2.0

Aug 25, 2006

I am new to ASP. I am trying to use "Filterexpression".
FilterExpression="(Address_no >= '@Startno') AND (Address_no <= '@Endno')" >
I could not get it work. Could someone help me? Here is my code.
__________________________________________________________________________________
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="FarmedStreet.aspx.vb" Inherits="FarmedStreet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvFarm" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataKeyNames="StreetID" DataSourceID="dsfarm"
Font-Bold="False" Font-Names="Arial" Font-Size="11pt" PageSize="5">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<Columns>
<asp:CommandField ShowSelectButton="True">
<ItemStyle ForeColor="#00C000" />
</asp:CommandField>
<asp:BoundField DataField="StreetID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="StreetID" />
<asp:BoundField DataField="StartNo" HeaderText="StartNo" SortExpression="StartNo" />
<asp:BoundField DataField="EndNo" HeaderText="Endno" SortExpression="EndNo" />
<asp:BoundField DataField="Street" HeaderText="Street" SortExpression="Street" />
<asp:BoundField DataField="Zip" HeaderText="Zip" ReadOnly="True" SortExpression="Zip" />
<asp:CheckBoxField DataField="IsFarming" HeaderText="?" SortExpression="IsFarming" />
<asp:CommandField ShowEditButton="True">
<ItemStyle ForeColor="#00C000" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="dsfarm" runat="server" ConnectionString="<%$ ConnectionStrings:cnFarming %>"
SelectCommand="SELECT __Street.StreetID, __Street.Street, __Street.ZipID, __Street.IsFarming, __Street.StartNo, __Street.EndNo, __Zip.Zip FROM __Street INNER JOIN __Zip ON __Street.ZipID = __Zip.ZipID WHERE (NOT (__Street.StartNo IS NULL)) AND (NOT (__Street.EndNo IS NULL))">
</asp:SqlDataSource>
<asp:Button ID="btnResident" runat="server" BackColor="#00C000" Enabled="False" Font-Bold="True"
ForeColor="Yellow" Text="Resident" />

</div>
<asp:SqlDataSource ID="dsResidentA" runat="server" ConnectionString="<%$ ConnectionStrings:cnFarming %>"
SelectCommand="SELECT ProspectID, FName, LName, SAddress, SCity, SState, SZip, MAddress, MCity, MState, MZip, Bed, Bath, [S FT], phone, City, Address_no, Street, CatID, PropID, StreetID, ZipID, Apt FROM __Prospect WHERE (StreetID = @StreetID)"
FilterExpression="(Address_no >= '@Startno') AND (Address_no <= '@Endno')" >
<SelectParameters>
<asp:ControlParameter ControlID="gvFarm" Name="StreetID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="gvFarm" Name="Startno" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="gvFarm" Name="Endno" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="dsResidentA" PageSize="5">
<Columns>
<asp:BoundField DataField="ProspectID" HeaderText="ProspectID" InsertVisible="False"
SortExpression="ProspectID" />
<asp:BoundField DataField="FName" HeaderText="FName" SortExpression="FName" />
<asp:BoundField DataField="LName" HeaderText="LName" SortExpression="LName" />
<asp:BoundField DataField="Address_no" HeaderText="Address_no" SortExpression="Address_no" />
<asp:BoundField DataField="Apt" HeaderText="Apt" SortExpression="Apt" />
<asp:BoundField DataField="PropID" HeaderText="PropID" SortExpression="PropID" />
</Columns>
</asp:GridView>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>

View 1 Replies View Related

FilterExpression

Jun 6, 2008

I have a CheckBoxList which is bound to a SQLDataSource and populated with a list of courses. Under this I have a calendar control which is bound to another SQLDataSource control. When the page is first loaded this is empty because no courses are selected. I'd like it so that the user can select one or more course from the CheckBoxList and the appropraite events are loaded into the calendar control bound to the second SQLDataSource. I've tried using FilterExpression but this seems to work on the basis of a complete resultset being loaded and then filtered-out using the FilterExpression. I'm starting with no records and would like to Filter-In data from the database.
Is this possible using FilterExpression?

View 3 Replies View Related

Recovery :: Configure Extended Event To Trigger A Mail Whenever Any Event Occurs

Jun 2, 2015

Recently we migrated our environment to 2012.

We are planning to implement Xevents in all the servers in place of Trace files and everything is working fine.

Is it possible to configure Extended event to trigger a mail whenever any event (example dead lock) occurs.

I have gone through so many websites but i never find.

View 13 Replies View Related

FilterExpression Syntax In C#

Aug 4, 2006

I have a some search components to filter a GridView follows:
<asp:DropDownList ID="ddFilterType" runat="server" ToolTip="Select field to search">   <asp:ListItem Selected="True">(ALL)</asp:ListItem>   <asp:ListItem>SKU</asp:ListItem>   <asp:ListItem>Vendor Name</asp:ListItem>   <asp:ListItem>Item Name</asp:ListItem></asp:DropDownList><asp:TextBox ID="txtSearchFilter" runat="server"></asp:TextBox><asp:LinkButton ID="btnSearchFilter" runat="server">Filter</asp:LinkButton>
and C# code as follows:
protected void Page_Load(object sender, EventArgs e){   if (IsPostBack)   {      if (ddFilterType.SelectedValue != "ALL")      {         dsItems.FilterExpression = (ddFilterType.SelectedValue = txtSearchFilter.Text);         gvItems.DataBind();      }      else { gvItems.DataBind(); }   }}
But when I run the search, I get:Exception Details: System.Data.EvaluateException: Cannot find column [the value in txtSearchFilter.Text].
How should I do my C# syntax to get this to work? Also, I would like to add further logic to check if the field is not the SKU field and have my expression do a LIKE expression instead of checking for equality. Any help with this is much appreciated.
Marc

View 1 Replies View Related







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