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
ADVERTISEMENT
Apr 15, 2004
Dear All:
I want to ask how can I handle OnError events in stored procedure in MSSQL.
Actually I wanted to place some Rollback procedure on this.
Can you suggest some methods for me?
KEVIN
View 1 Replies
View Related
Jun 19, 2008
I've posted a few questions on what we dba's let the developers do in a production database and the consensus seems to be not to let them issue DDL cmds e.g. create table, views ... This brings me to this question on how do you handle the developers requests for changes in a production database. If anyone is willing to post their requirements I'd really appreciate it. I'm thinking about a master excel sheet on that would contain fields for the request but I want to make sure I'm getting everything that I need.
Thanks in Advance
View 7 Replies
View Related
Feb 15, 2007
Hello,
Please, help with following issues.
I have 3 parameters in the report. When user selects 1st one from dataset, one of the fields gives me object creation date. Calendar control is supposed to be filtered to allow users select the dates greater than selected one.
How can I filter (disable dates in) calendar control?
Any suggestion/comment highly appreciated
View 2 Replies
View Related
Mar 25, 2008
Hi All,
I need to send out email when error occurs in the package. Is it a good practice to put the send email task in the event handler? Then MaximumErrorCount is set to 1. But for some reason, some time I saw more than one email are sent out. Please advise. Thanks
View 6 Replies
View Related
Aug 3, 2006
Hi All,
I have following:
a text input for filtering
a gridview that displays the data
an SqlDataSource that contains the query.
Users can either enter something into the text input or leave it blank. Depending on that, the gridview should either display all data (unfiltered, because nothing was entered into the text field) or filtered data (when something is entered).
Now my problem is in defining the query in the SqlDataSource. I could do something like this:
SELECT * FROM myTable WHERE myField = @p1;
and then add in the appropriate <asp:ControlParameter /> under the <SelectParameters> tag. However, this sorta "fixes" the filter. Regardless of whether users actually type something in or not, the filter is in effect. I want it in such a way that if users do not type in anything, the query essentially becomes:
SELECT * FROM myTable;
Is there any way to achieve this?
Thanks in advance,
jason
View 5 Replies
View Related
Mar 27, 2006
I think I might be missing something here.
Here is what I'd like to do:1. Retrieve a list of data from SQL Server.2. Display that data in a gridview.3. Have the user click on a button to then see a subset of that data. (filtering)
I can't seem to make this work. When the user clicks the button, I need the GridView to update to show only the specified data. In 1.1 I would created a DataView for the filtering, but am trying to use the latest and greatest.
I've seen examples online of people using DropDownLists to act as the dynamic filter parameter. How can I programatically assign this to make it work?Thanks!
View 1 Replies
View Related
May 29, 2007
Greetings,
I have a question about the best method to ensure the proper flow of control within a package. I have three related SQL tasks €“ A, B, and C €“ that must execute in sequence. If any one of the tasks fails then the remaining tasks should not execute because each is dependent on the previous step. (A €œsuccess€? precendence constraint.)
Likewise, I have a second set of SQL tasks €“ 1, 2, and 3 €“ that must execute in sequence. Task 3 should never execute unless tasks 1 and 2 have been successful.
I consider these to be two independent logic paths in the same package and, indeed, when I run the package both task A and task 1 begin running at the same time.
What I€™m not sure of is how to add a new task €“ Z €“ that will execute only after both the A-B-C and 1-2-3 task paths have completed. Diagramatically, this would be like having a €œcompletion€? constraint linking task C to task Z and another €œcompletion €œ constraint linking task 3 to task Z. In other words, the two independent paths merge at task Z. Task Z is an audit step that must always run €“ it emails summaries of the database activities performed by the other tasks.
What has me puzzled is how I get to Z when there is a failure in either the A-B-C path or the 1-2-3 path. As things stand now, the package will never reach task Z if there is a failure in an earlier task because they are joined by a €œsuccess€? constraint.
I thought I could get around this by using a €œsequence container€? but I discovered when I added A, B, and C to a container that I couldn€™t use the €œsuccess€? constraint I needed. I was just guessing that this might be the way to do it.
Can anyone help me with a best practice approach to the control flow issue I face? I€™m new if that isn€™t apparent by my question, so don€™t be afraid to make your answer simple and plain.
Thanks for any help,
BCB
View 7 Replies
View Related
Oct 12, 2006
i HAVE TRIED THE FOLLOWING CODE BUT ITS NOT WORKING AS I WANT TO FILTER IT ACCORDING TO THE VALUE OF DROPDOWNLIST I HAVE TRIED CONFIGURE THE SQLDATASOURCE. DATASOURCE MODE PROPERTY IS SET TO THE DATASERSTILL IT IS NOT SHOWING ANY RESULTS <%@ Page Language="VB" %> <!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> <h3>Search Jobs</h3> <table cellspacing="10"> <tr> <td valign="top" style="height: 162px"> <table border="0"> <tr> <td valign="top" style="width: 70px"> Location</td> <td><asp:DropDownList runat="server" id="CountryListBox" AppendDataBoundItems="True" DataSourceID="CountrySqlDataSource" DataTextField="location" DataValueField="location" AutoPostBack="True" > <asp:ListItem Selected="True" >(Show All)</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td style="width: 70px"> Skills</td> <td><asp:TextBox runat="server" id="LastNameTextBox" Text="*" /></td> </tr> <tr> <td style="width: 70px"></td> <td><asp:Button runat="server" id="FilterButton" Text="Filter Results" /></td> </tr> </table> </td> <td valign="top" style="width: 587px; height: 162px;"> <asp:GridView ID="EmployeesGridView" DataSourceID="SqlDataSource2" DataKeyNames="employeeID" AutoGenerateColumns="False" AllowSort="True" RunAt="server" Height="143px"> <HeaderStyle backcolor="Navy" forecolor="White"/> <RowStyle backcolor="White"/> <AlternatingRowStyle backcolor="LightGray"/> <EditRowStyle backcolor="LightCyan"/> <Columns> <asp:BoundField DataField="employeeID" HeaderText="employeeID" ReadOnly="True" SortExpression="employeeID" /> <asp:BoundField DataField="employeeName" HeaderText="employeeName" SortExpression="employeeName" /> <asp:BoundField DataField="companyName" HeaderText="companyName" SortExpression="companyName" /> <asp:BoundField DataField="jobSkills" HeaderText="jobSkills" SortExpression="jobSkills" /> <asp:BoundField DataField="experiance" HeaderText="experiance" SortExpression="experiance" /> <asp:BoundField DataField="location" HeaderText="location" SortExpression="location" /> </Columns> </asp:GridView> </td> </tr> </table> <asp:SqlDataSource ID="CountrySqlDataSource" SelectCommand="SELECT DISTINCT location FROM tlbEmployee" EnableCaching="True" CacheDuration="60" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" RunAt="server" /> <asp:SqlDataSource ID="EmployeeDetailsSqlDataSource" SelectCommand="SELECT * FROM [tlbEmployee] WHERE (([location] LIKE '%' + @location + '%') AND ([jobSkills] LIKE '%' + @jobSkills + '%'))" EnableCaching="True" CacheDuration="60" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" FilterExpression="location LIKE '{0}' AND jobSkills LIKE '{1}'" RunAt="server"> <FilterParameters> <asp:ControlParameter ControlID="CountryListBox" PropertyName="SelectedValue" /> <asp:ControlParameter ControlID="LastNameTextBox" PropertyName="Text" /> </FilterParameters> <SelectParameters> <asp:ControlParameter ControlID="CountryListBox" Name="location" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="LastNameTextBox" Name="jobSkills" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT DISTINCT location FROM tlbEmployee"></asp:SqlDataSource> </div> <asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource> </form></body></html>
View 1 Replies
View Related
Aug 29, 2006
Hi -- I'm starting an ASP.NET 2.0 application which contains a page with a checkbox and gridview control on it. In its default state the gridview displays all the records from a table pulled from a SQL Server database (via a SqlDataSource object). When the user checks the checkbox, I want the gridview to display only the records where one of the columns is not null. But I've been unable to construct the WHERE clause of the SQLDataSource object correctly. I see that I can hard-code the SqlDataSource object so that the column to be filtered is always NULL or always NOT NULL. But I want this filtering to be more dynamic such that the decision to show all or non-null records happens at run-time. Should I be using two SqlDataSource objects -- one for the NOT NULL condition and one for the "all records" condition? Then when the user checks the checkbox, the gridview would be configured to point to the appropriate SqlDataSource object. (???) Seems like a bit of overhead with that approach. I'm hoping there's a more elegant way to get this done. Please let me know if you need more information. Thanks in advance. Bill
View 2 Replies
View Related
Oct 17, 2007
Hi there,
Version : Framework 2,0 (assemly: C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Windows.Forms.dll)
The debuger hangs at the line e.Cancel = true in RowValidation event with 100% cpu ,when the focus go out of
SplitContainer .
i am using visual studio 2005 professional , with service pack1..
Appriciate your help.
thanks
oz
--
private void INVOICEDETAILDataGridView_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
if (!INVOICEDETAILDataGridView.IsCurrentRowDirty) return;
DataGridViewRow CurRow = this.INVOICEDETAILDataGridView.Rows[e.RowIndex];
if (CurRow.Cells["ACCOUNT"].value.ToString().Trim().Length < 1)
{
MessageBox.Show(ex.Message, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
}
View 1 Replies
View Related
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.
<asp:SqlDataSource OnSelecting="GetData_Selecting" ID="DS1" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" ProviderName="<%$ ConnectionStrings:MyConnectionString.ProviderName %>" runat="server" SelectCommand="" />
<asp:SqlDataSource OnSelecting="GetData_Selecting" ID="DS2" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" ProviderName="<%$ ConnectionStrings:MyConnectionString.ProviderName %>" runat="server" SelectCommand="" />
protected void GetData_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Getting Data...");
switch ((sender as SqlDataSource).ID)
{
case "DS1":
if (Checkbox1.Checked)
{
e.Command.CommandText = "SELECT * FROM table1 WHERE " + BuildQuery(getMylarColumns(), SearchBox.Text);
DS1Panel.Visible = true;
}
break;
case "DS2":
if (Checkbox2.Checked)
{
e.Command.CommandText = "SELECT * FROM table2 WHERE " + 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
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
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
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
p
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
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
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
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
Mar 18, 2008
I have a gridview connected to a sqldatasource, and it works pretty good. It gives me the subsets of the information that I need. But, I really want to let them choose all the companies and/or any status. What's the best way to get all the values in the gridview...besides removing the filters :)
I thought the company would be easy, I'd just set the selected value to blank "", and then it'd get them all....but that's not working. And, for the boolean, I have no idea to get the value without having a separate query.
(tabs_done=@tabsdone) and (company like '%' + @company + '%')1 <asp:DropDownList ID="drpdwnProcessingStatus" runat="server">
2 <asp:ListItem Value="0">Open</asp:ListItem>
3 <asp:ListItem Value="1">Completed</asp:ListItem>
4 </asp:DropDownList>
5
6
7 <asp:DropDownList ID="drpdwnCompany" runat="server">
8 <asp:ListItem Value="">All</asp:ListItem>
9 <asp:ListItem Value="cur">Cur District</asp:ListItem>
10 <asp:ListItem Value="jho">Jho District</asp:ListItem>
11 <asp:ListItem Value="sea">Sea District</asp:ListItem>
12 <asp:ListItem Value="san">Net District</asp:ListItem>
13 <asp:ListItem Value="sr">Research District</asp:ListItem>
14 </asp:DropDownList>
15
16
17 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HRFormsConnectionString %>"
18 SelectCommand="SELECT DISTINCT [id], [lastname], [company] FROM [hr_term] hr where (tabs_done=@tabsdone) and (company like '%' + @company + '%')">
19 <SelectParameters>
20 <asp:ControlParameter ControlID="drpdwnProcessingStatus" DefaultValue="0" Name="tabsdone" PropertyName="SelectedValue" />
21 <asp:ControlParameter ControlID="drpdwnCompany" DefaultValue="" Name="company" PropertyName="SelectedValue" />
22 </SelectParameters>
23 </asp:SqlDataSource>
24
View 3 Replies
View Related
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
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
Oct 23, 2007
please explain selectparameters and conflict detection property within sqldatasource control
mohsen
View 1 Replies
View Related
May 6, 2008
hi friends,
I created sqldatasource control. In select command i written the query like this "select * form emp" and bounded in grid.How can I change the query for searching the details according the date wise when i click the search button.
View 14 Replies
View Related
Jun 7, 2008
Hello experts
i have a SqlDataSource Control on my web form. Here is the source for the control
<asp:SqlDataSource ID="sqlSearchDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DbefomsConnectionString %>"
SelectCommand="SELECT [icon], [file_name], [path] FROM [tblfile] WHERE ([file_name] = @file_name)">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" DefaultValue="0" Name="file_name" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
This control displays icon, file_name, path in GridView Control
The problem is How can i store the above field values in an asp.net variable.
Thanks
Regards
Ali
View 1 Replies
View Related
Dec 7, 2005
Do you have to use the sqldatasource in conjuction with another control like gridview or dropdown list?
I'd like to check to see if a record exists in one table before inserting data into another.
thanks
View 1 Replies
View Related
Jan 31, 2006
Hello.I'm new to ASP.NET and trying to write data to a Microsft SQL Server. I have created a SqlDataSource control, which is 'connected' to my SQL server.Now my question is how i can put data in the database throw the control, and read data from it. I've read the site, but it's still unclear for me..Greetings!
View 1 Replies
View Related
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
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
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
View Related
Aug 8, 2006
How do you set a timeout for an SqlDataSource control?
View 1 Replies
View Related
Jan 16, 2007
Anyone can help me ?
View 4 Replies
View Related
Jan 19, 2007
Hello:
I am having a little issue with an error that is frustrating me. I have a SqlDataSource within an asp:label control and also have a two dropdownlists inside that asp:label control also. When I select from the first dropdownlist, it should enable the second dropdownlist with the populated data, but instead I receive.
The SqlDataSource control 'sqlGetMLSByCity' does not have a naming container. Ensure that the control is added to the page before calling DataBind.
Any ideas why this would be? Here is the web from portion:
<asp:Label ID="recip_form_request" runat="server" Visible="false"> <ul> <li>Step one: Select listing type.</li> <li>Step two: Select the City that you are reciprocating to.</li> <li>Step three: Complete the Recip Form.</li> </ul> <asp:DropDownList ID="recip_form_type" runat="server" AutoPostBack="true" Visible="False"> <asp:ListItem Value="0" Text="(Select Form)"></asp:ListItem> <asp:ListItem Value="1" Text="Residential"></asp:ListItem> </asp:DropDownList> <br /> <asp:DropDownList ID="outside_assoc_cities" runat="server" AutoPostBack="True" Enabled="False" DataTextField="city" DataValueField="id" Visible="False"></asp:DropDownList><br /> <asp:Label ID="city_mls_desc" runat="server"></asp:Label><br /> <asp:Button ID="page1_btn" runat="server" Text="Next >>" Visible="False" /> <asp:SqlDataSource ID="sqlCities" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>" SelectCommandType="Text" SelectCommand="SELECT id, city FROM tCityMaster"></asp:SqlDataSource> <asp:SqlDataSource ID="sqlGetMLSByCity" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>"> <SelectParameters> <asp:ControlParameter ControlID="outside_assoc_cities" Name="City" /> </SelectParameters> </asp:SqlDataSource></asp:Label>
then the code behind:
Protected Sub outside_assoc_cities_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles outside_assoc_cities.SelectedIndexChanged If outside_assoc_cities.SelectedIndex > -1 Then Dim ItemId As Integer = Integer.Parse(outside_assoc_cities.SelectedValue) Dim MLSID As String = Nothing
Dim cmd As New SqlCommand Dim con As New SqlConnection cmd.Connection = con
Dim sqlGetMLSByCity_sql As SqlDataSource = CType(Page.FindControl("sqlGetMLSByCity"), SqlDataSource) 'using connectionstring from SqlDataSource Control con.ConnectionString = sqlGetMLSByCity_sql.ConnectionString 'con.ConnectionString = sqlGetMLSByCity.ConnectionString
cmd.CommandType = CommandType.Text cmd.CommandText = "SELECT mls_id FROM pwaordev..tCityMaster WITH(NOLOCK) WHERE ID=@ID"
cmd.Parameters.Add("@ID", SqlDbType.Int, 4).Value = ItemId
Try con.Open() MLSID = cmd.ExecuteScalar con.Dispose() cmd.Dispose() Catch ex As Exception con.Dispose() cmd.Dispose() Response.Write(ex.ToString()) End Try
'Further logic to display button depending on MLS If Not String.IsNullOrEmpty(MLSID) Then If MLSID = "B" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Greater South Bay MLS." page1_btn.Visible = True ElseIf MLSID = "A" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Big Bear BOR, MLS, which is not covered by Pacific West Association of REALTOR®, please contact us for more information." page1_btn.Visible = False ElseIf MLSID = "C" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Combined L.A./Westside MLS." page1_btn.Visible = True ElseIf MLSID = "F" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Crisnet MLS, which is not covered by Pacific West Association of REALTOR®, please contact us for more information." page1_btn.Visible = False ElseIf MLSID = "Y" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is DCAoR - Yucca Valley Area, which is not covered by Pacific West Association of REALTOR®, please contact us for more information." page1_btn.Visible = False ElseIf MLSID = "D" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Desert Area MLS." page1_btn.Visible = True ElseIf MLSID = "L" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is i-Tech Glendale/Pasadena." page1_btn.Visible = True ElseIf MLSID = "M" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is MRM - Multi-Regional MLS." page1_btn.Visible = True ElseIf MLSID = "R" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is RIM - Rim of the World MLS, which is not covered by Pacific West Association of REALTOR®, please contact us for more information." page1_btn.Visible = False ElseIf MLSID = "G" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SDI - San Diego, which is not covered by Pacific West Association of REALTOR®, please contact us for more information." page1_btn.Visible = False ElseIf MLSID = "S" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SOCAL MLS - Southern California MLS." page1_btn.Visible = True ElseIf MLSID = "T" Then city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Outside Area, which is not covered by Pacific West Association of REALTOR®, please contact us for more information." page1_btn.Visible = False End If 'test.Text = MLSID 'If test.Text = "L" Then 'mls_text.Text = "i-Tech" 'End If End If End If End Sub
Any help would be great, thank you!
View 1 Replies
View Related
Sep 20, 2007
I have an SqlDatSource that I have fully setup at design time, but I don't want it to open and load as soon as the page loads, instead I want to open it based on a condition.
How do you do that with a DataSource?
I know that I can simply remove the Select query, and then set it at run time, but I'm looking for something better, that allows me to have the Select query set at design time, in part because I have a lot of parameters.
View 3 Replies
View Related