 |
| ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 21st, 2009, 12:02 PM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
Name 'ddlColumnName'
Error 1 Name 'ddlColumnName' is not declared.
If I declar ddlColumnName
Dim ddlColumnName As New ddlColumnName
it will ask me for type
Please can i have some help with this
|
|

November 21st, 2009, 12:04 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
It would help if you'd specify where you get the error "Name 'ddlColumnName' is not declared."....
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

November 21st, 2009, 12:13 PM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
ddlColumnName
This is the code I am using
[Code]
Protected Sub btnFilter_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim AccessDataSource1 As New AccessDataSource
Dim FilterExpression As String = String.Concat(ddlColumnName.SelectedValue, " LIKE '%{0}%'")
AccessDataSource1.FilterParameters.Clear()
AccessDataSource1.FilterParameters.Add(New ControlParameter(ddlColumnName.SelectedValue, "txtFilterExpression", "Text"))
AccessDataSource1.FilterExpression = FilterExpression
End Sub
Protected Sub PopulateDropDownListWithColumnNames()
Dim GridView1 As New GridView
For Each col As BoundField In GridView1.Columns
ddlColumnName.Items.Add(New ListItem(col.HeaderText, col.HeaderText))
Next
End Sub
[Code\]
|
|

November 22nd, 2009, 04:59 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Did you copy and paste this code from some example? It looks as if ddlColumnName should be declared in the markup (with <asp:DropDownList id="ddlColumnName" runat="server" />), resulting in a drop-down list in the browser. There's not much point instantiating one in the code as it won't get a value correctly.....
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

November 22nd, 2009, 04:13 PM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
DataGrid to filter name
Yes I used a example and modefied it
I have tried to do this another way and it loads when i debug
But when I select a employee and press filter it will not work?
[code]
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnFilter_Click(ByVal sender As Object, ByVal e As EventArgs)
AccessDataSource1.SelectParameters.Clear()
Dim sqlSelectCommand As String = String.Concat(AccessDataSource1.SelectCommand, " WHERE Site_Employee LIKE '%'+?+'%'")
AccessDataSource1.SelectCommand = sqlSelectCommand
AccessDataSource1.SelectCommandType = SqlDataSourceCommandType.Text
AccessDataSource1.SelectParameters.Add(New ControlParameter("Site_Employee", "txtFilterCriteria", "Text"))
End Sub
Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
ResetDataSource()
End Sub
Protected Sub ResetDataSource()
'Remove the filter from the default select statement by using
'a new T-SQL statement that has no " where " clause.
AccessDataSource1.SelectCommand = "Select * From SWR2010"
End Sub
Protected Sub txtFilterCriteria_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
|
|

November 22nd, 2009, 04:41 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
You're not really providing the information needed to solve this problem. Since it's only a bit of code that also requires a database, it's not something we can try out in a debugger and see how it behaves. So, you'll need to provide more information. What exactly are you trying to accomplish? How does your markup section look like? What does "it will not work" mean exactly? Do you get an error? If so, which one?
And so on, and so forth.... ;-)
Cheers,
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

November 22nd, 2009, 05:08 PM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
DataGrid to filter name
Can I send you the Project?
|
|

November 22nd, 2009, 05:17 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Not if you can't explain what the problem is, or what you're trying to accomplish. I don't mind looking at your project, but I don't feel like wading through loads and loads of pages, half working code and out-dated comments ;-)
If you can't explain the desired behavior and errors you're getting for a single method in code behind, I am worried about looking at the entire project. Agree?
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|
 |