p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/forumdisplay.php?f=351)
-   -   Name 'ddlColumnName' (http://p2p.wrox.com/showthread.php?t=77117)

headworth November 21st, 2009 12:02 PM

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

Imar November 21st, 2009 12:04 PM

It would help if you'd specify where you get the error "Name 'ddlColumnName' is not declared."....

Imar

headworth November 21st, 2009 12:13 PM

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\]

Imar November 22nd, 2009 04:59 AM

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

headworth November 22nd, 2009 04:13 PM

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

Imar November 22nd, 2009 04:41 PM

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

headworth November 22nd, 2009 05:08 PM

DataGrid to filter name
 
Can I send you the Project?

Imar November 22nd, 2009 05:17 PM

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


All times are GMT -4. The time now is 10:50 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.