This is a discussion on ASP.NET Data Controls within the ASP and ASP.NET Programming forums, part of the Web Development category; hi, I am getting an error :\Users\tmarie\Documents\MSDN\test\secure_members\ OrderSearch.aspx(26) : error BC30451: Name 'CustomerID' is ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#61
| |||
| |||
| hi, I am getting an error :\Users\tmarie\Documents\MSDN\test\secure_members\ OrderSearch.aspx(26) : error BC30451: Name 'CustomerID' is not declared. SqlDataSource1.SelectCommand = "SELECT [ORDERID], [STATUS], [CUSTOMERID], [CUSTOMER_PO] FROM [test.csv] WHERE CUSTOMERID = " & CustomerID() ~~~~~~~~~~ C:\Users\tmarie\Documents\MSDN\test\secure_members \OrderSearch.aspx(27) : error BC30455: Argument not specified for parameter 'arguments' of 'Public Function Select(arguments As System.Web.UI.DataSourceSelectArguments) As System.Collections.IEnumerable'. SqlDataSource1.Select() ~~~~~~~~~~~~~~~~~~~~~~~ C:\Users\tmarie\Documents\MSDN\test\secure_members \OrderSearch.aspx(35) : error BC30455: Argument not specified for parameter 'arguments' of 'Public Function Select(arguments As System.Web.UI.DataSourceSelectArguments) As System.Collections.IEnumerable'. SqlDataSource1.Select() ~~~~~~~~~~~~~~~~~~~~~~~ I thought that i declared 'CustomerID at the top. and where in the Page_Load event do i put the if post back? code i have right now. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" %> <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Not Page.IsPostBack Then Session("CustomerID") = Nothing If User.Identity.IsAuthenticated Then If User.IsInRole("admin") Then If Request("CustomerID") IsNot Nothing Then Session("CustomerID") = Request("CustomerID") End If Else Session("CustomerID") = User.Identity.Name End If End If 'SqlDataSource1.SelectCommand = "SELECT [ORDERID], [STATUS], [CUSTOMERID], [CUSTOMER_PO] FROM [test.csv] WHERE CUSTOMERID = " & CustomerID() 'SqlDataSource1.Select() 'GridView1.DataBind() End If If Not IsPostBack Then SqlDataSource1.SelectCommand = "SELECT [ORDERID], [STATUS], [CUSTOMERID], [CUSTOMER_PO] FROM [test.csv] WHERE CUSTOMERID = " & CustomerID() SqlDataSource1.Select() GridView1.DataBind() End If End Sub Protected Sub Search_Click(ByVal sender As Object, ByVal e As System.EventArgs)SqlDataSource1.SelectCommand = "SELECT * FROM [test.csv] WHERE " & DropDownList1.SelectedItem.Text & " = " & txtSearch.Text SqlDataSource1.Select() GridView1.DataBind() End Sub </script> <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" SkinID="KylieSkin" EmptyDataText="There are no data records to display." AllowPaging="True" AllowSorting="True" PageSize="20"> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT [ORDERID], [STATUS], [CUSTOMERID], [CUSTOMER_PO] FROM [test.csv] WHERE ([CUSTOMERID] = ?)" /> <selectparameters> <asp:SessionParameter Name="CUSTOMERID" SessionField="CUSTOMERID" Type="String" /> </selectparameters> </asp:SqlDataSource> <asp ropDownList ID="DropDownList1" runat="server"><asp:ListItem Value="Customer_PO">Customer P.O.</asp:ListItem> </asp ropDownList><asp:TextBox ID="txtSearch" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="search" /><br /> </asp:Content>
__________________ H2O Without us, no one can survive.. |
|
#62
| |||
| |||
| hi, If you look at my code in the previous post, I have take removed the SelectParameters and using SelectCommand itself to create my query. That is the one of the reason why you are getting the error. Secondly in the Page_Load event in the Not IsPostback section, I have remarked that you have to check your CustomerID there. So I was assuming that you would have a variable called CustomerID and was using this variable in the SelectCommand. In your code, you are using it as a function called CustomerID() and not as a variable. If Not IsPostBack Then ' Do your checking for CustomerID dim CustomerID as Integer = Cint(Session("CustomerID")) SqlDataSource1.SelectCommand = "SELECT [ORDERID], [STATUS], [CUSTOMERID], [CUSTOMER_PO] FROM [test.csv] WHERE CUSTOMERID = " & CustomerID SqlDataSource1.Select() GridView1.DataBind() End If In the above code, I haven't done any error checking.
__________________ Venkat knowledge is Power |
|
#63
| |||
| |||
| hi guys, I have my ODS in SP, I've problem to choose the column in the Table (the part which I bold the font below), it is syntax error. Any comment? Thanks for helps.. SELECT SampleToolItem .*, Creators.UserName ItemCreatorDisplayName FROM SampleToolItem INNER JOIN aspnet_users AS Creators ON Creators.UserId = SampleToolItem.ItemCreatorId Where SampleToolItem.@ddl = @tb |
|
#64
| |||
| |||
| hi, SampleToolItem.@ddl = @tb @ddl is a variable and you cannot (as far as I know) reference a column name like this. SampleToolItem.ItemID = @ItemID In the above SampleToolItem is your tablename, ItemID is your column(or field) in your table and @ItemID is the variable that you are passing.
__________________ Venkat knowledge is Power |
|
#65
| |||
| |||
| hi venkat, Ya,that is the problem. Actually I have a search function for GV which consist of a Dropdownlist(search by) and a Textbox. So, I can't assign the static column name in the SP but have to depend on the selection by user. Maybe there are alternative solution for this? Or how can I reference to the column name selected by user?(the @ddl) Thanks a lot! |
|
#66
| |||
| |||
| hi kingmaker, If you are setting the SelectCommand then you can do this. SqlDataSource1.SelectCommand = "SELECT * FROM [test.csv] WHERE " & ColumnName & " = " & searchCriteria If you are using Stored procedure and columnname and searchcriteria as parameters, then you have to do DECLARE @SQLQUERY VARCHAR(1000) SET @SQLQUERY = N'SELECT * FROM TABLE1 WHERE ' + QUOTENAME(@COLUMNNAME) + ' = ' + @SearchCriteria EXEC (@SQLQUERY) In the above QuoteName is used to thwart Sql injection.
__________________ Venkat knowledge is Power |
|
#67
| |||
| |||
| hi, When I do like that, it force me to key in the textbox's text exactly same as the ddl's item value. Example: <asp ropDownList ID="ddlSearch" runat="server"><asp:ListItem Value="ModelName">Model Name</asp:ListItem> <asp:ListItem Value="ModelNo">Model No</asp:ListItem> </asp ropDownList> if I key in "name1", the error is: Invalid column name 'name1 if I key in "ModelName", display all the GV rows |
|
#68
| |||
| |||
| hey guys, I solve it by: WHERE CASE WHEN @ddl='ModelName' THEN ModelName WHEN @ddl='ModelNo' THEN ModelNo END =@tb Thanks for help ![]() Wish to know other method if u have other ideas, thanks ![]() |
|
#69
| |||
| |||
| Hi guys, I am trying send an email when a row in my gridview has been updated based on a checkbox in grideview = true. I Keep getting the error "object reference not set to an insatnce of an object" I am assuming that this is because the code isn't finding the checkbox. I have editing enable for the gridview.....What is the name of the checkbox ( in edit mode ) in the grid view. My aspx page contains <asp:CheckBoxField DataField="ApprovedBy_HR" What should my code behind use to refernce this.. I tried the following Dim VarHRApproved As CheckBox = CType(GridView1.FindControl("ApprovedBy_HRCheckBox "), CheckBox) If VarHRApproved.Checked = True Then 'create the mail message Thx in advance,
__________________ H2O Without us, no one can survive.. |
|
#70
| |||
| |||
| hey H2o, Since we don't know the name of the control, you simply pull the control out of the specific cell's control collection. For example, if your CheckBoxField was the first column of your GridView, then you'd retrieve the CheckBox reference like so: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow gvr = e.Row; if (gvr.RowType == DataControlRowType.DataRow) { CheckBox chk = gvr.Cells[0].Controls[0] as CheckBox; } }
__________________ Venkat knowledge is Power |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| silverlight controls for .net | stevejhon | ASP and ASP.NET Programming | 1 | 03-25-2009 10:31 AM |
| silverlight controls for .net | stevejhon | ASP and ASP.NET Programming | 0 | 03-23-2009 01:55 AM |
| How can we Dynamically create web controls | Kirubhananth | ASP and ASP.NET Programming | 3 | 03-14-2008 09:00 PM |
| WebParts controls | S.Vinothkumar | ASP and ASP.NET Programming | 5 | 11-16-2007 02:06 AM |
| Asp.net controls not supported by Ajax? | Gopisoft | ASP and ASP.NET Programming | 0 | 07-16-2007 11:22 PM |
Our Partners |