Forms Data Controls :: Use A Query String Variable Created On The Fly To Populate A Child Webpage?
Feb 22, 2010
I have developed the below web page which has an asp.net 3.5 listview control as it's frontend and an sql server db as it's backend.
[URL]
The first row on the web page is the inserting row. What I am hoping to achieve is that when the user enters their appropriate data they click the "Next" button to assign this dataset with it's own identity ID (customer_id) value within my database (this works perfectly), at the same time on the fly I want to use this customer_id as a query string variable to populate a child page (customerTrades.aspx) in order to pin further data to this identity. Currently I am attempting to use the below code within the iteminserted event of my listview control but I receive the error: "object reference not set to the instance of an object"??
protected void lvTrustAccounts_ItemInserted(object sender,
ListViewInsertedEventArgs e)
{
string customerID = e.Values["customer_id"].ToString();
Response.Redirect("http://www.tradeselector.co.uk/customerTrades.aspx?customer_id="
+ customerID + "");
}
Is this because the child page cannot find the customer_id variable being passed through the query string? Because it's not actually created yet? Am I using the wrong listview event? How can I achieve what I am looking for?
I must also mention that I'm using a linqdatasource to insert my data on runtime into my database. However, I am using the listview iteminserting event to insert my frontend dropdownlist selected values, code below:
protected void lvTrustAccounts_ItemInserting(object sender,
ListViewInsertEventArgs e)
{
e.Values["customer_created_date"]
= DateTime.Now;
e.Values["customer_update_date"]
= null;
DropDownList ddl_CountyInsert =
(DropDownList)lvTrustAccounts.InsertItem.FindControl("CountyInsertDDL");
DropDownList ddl_CityInsert =
(DropDownList)lvTrustAccounts.InsertItem.FindControl("CityInsertDDL");
DropDownList ddl_CountryInsert =
(DropDownList)lvTrustAccounts.InsertItem.FindControl("CountryInsertDDL");
e.Values["customer_county_code"]
= ddl_CountyInsert.SelectedValue;
e.Values["customer_city_code"]
= ddl_CityInsert.SelectedValue;
e.Values["customer_country_code"]
= ddl_CountryInsert.SelectedValue;
}
View 11 Replies
Similar Messages:
Jul 13, 2010
I'm encountering a strange problem. Here is the scenario. I have built a query that accepts a parameter (WHERE LIKE clause).
I've tested this within the query builder and it returns exactly the number I would expect.
I then go back to my webpage and add the following controls:
Dropdown
Gridview
the user to make a selection from the dropdown. Postback on the dropdown is enabled so the page reloads and the Gridview displays the filtered results (via an objectdatasource). I've set the parameter to the dropdown control.
The trouble is when I run the page I make the selection in the dropdown no results are displayed. Even though the text displayed in the dropdown control is exactly the same as I inputted into the query builder when testing it.
View 3 Replies
May 7, 2015
If that Possible then How?
Response.Redirect("Manage Admin.aspx?AdminId=Select AdminId from Admins where UserName=" + Session["AdminSession"]);
View 1 Replies
Jul 16, 2010
How to display the string data stored in a string[] variable into gridview?
View 9 Replies
Sep 13, 2010
In my website, where majority of the users are from Norway,I access some values via querystring(eg: email address).Since the members' email ID may contain Latin letters,I am confused and blocked at this level.
My requirements are,
1, I need to access the Latin letters from query string. Is there any thing different from normal query string operations?
2, I need to store these latin Email IDs to my DB ,which is mysql.Any precaution to be taken while storing latin letters to mysql?
3, I need to show these stored email IDs in my web page.Should I use localization(which I have not used yet) for correctly displaying latin letters in webpage?
View 2 Replies
Jul 22, 2010
I am having a problem populating my drop down list from my query.
Here is the code I am using:
[code]....
I still get an empty drop down I am sure I am missing something simple.
View 3 Replies
Sep 20, 2015
How to populate or bind TreeView from one table use SQLSERVER database in ASP.NET & C# table include
ID,Name,ParentID
View 1 Replies
Jan 12, 2011
How would I take a text box value and use it in the query string on submit? I'd like it to start as this,
/News?favorites=True
and end up something like this after the user enters in a search and clicks search.
/News?query=test&favorites=True
The controller action looks like this
public ActionResult Index(string query,bool favorites)
{
//search code
}
View 1 Replies
Apr 21, 2010
I have a Gridview which I'm populating through code behind. A couple of columns of the gridview I've set up to be drop down lists. What I want, is that when I run my Insert query, it takes the drop down list selected value, finds the appropriate ID and uses that ID as part of the insert query.
Below is my select and insert query.
[Code]....
This is the related asp:
[Code]....
View 22 Replies
Jan 17, 2011
I am using a dataset control and I have 5 dropdown lists in which their content depends on what item is selected in each dropdown list.
I know I can populate the lists with 5 different queries taking the variables from each list but I am thinking there must be a better way.
Is there a way to populate each list with one query that takes the distinct items from each column returned without looping through the entire recordset?
View 2 Replies
Jan 26, 2011
I have a gridview with column name:
Pending, Waiters, Opened
and in the rows under column there are figures like:
30, 50, 28
65, 0, 214 etc.
My program is working fine, when I am clicking 30, a new page opens and displays 30 rows, when I click 28 another page opens and displays 28 rows and so on.
In datatable there is a column named Stauts, actually Pending, Waiters,Opened are the status.
In dataset in table adapter I used thress queries one for "Pending", second for "Waiters" and third for "Opened".
To display data I created three pages with gridviews.
I used query like:
Select * from ..... Where status ='Pending'
Select * from ..... Where status ='Waiters'
Select * from ..... Where status ='Opened'
What is Required:
I want to make one query with status =@status and want to use header name in query or in vb.net coding and want to make only one page to display record.
To put my question as an idea/example I used three status but in real scenarion I have lot of status. If I have lot of status so I have to make lot of queries and have to create lot of aspx pages to display data in gridview that is not the correct logic.
View 4 Replies
Aug 30, 2010
Example scenario:
User login has a list of associated 'accounts' it has access to... this list of accounts is stored in a database table, say tblAccountAccessControl, something like:
login, accountID
userA, account123
userA, account456
userA, account798
userB, accountABC
userB, accountDEF
etc..
This info is used throughout the web application and determines the 'domain' of information the particular login has access to. For example there are many other tables that have the 'accountID' field and whenever a page pulls data from the table it only pulls data that the currently logged in user should be allowed to see, based on that tblAccountAccessControl data.
The security question:
Do I need to query the database every time I need to get this list of allowed accountID's? I was about to use a plain old query string to pass a particular accountID to another page but quickly caught myself as I realized that would be a major security flaw (the receiving page was going to use that accountID to grab info from the database, and there would be nothing preventing a user from simply typing in a url manually to get data from an accountID they are not supposed to be allowed to view). So I then thought I'll just store the list of accountID's in a session state variable so they will be carried with the user throughout the session.
But then I remembered there are tools out there that allow you to easily intercept and modify asp.net viewstate information and I'm not sure if that would included session state variables, but I'm guessing they would. Is there a way to create a secure query string? If I used session state would that session state information be exposed and modifyable by utilities out there? Am I just stuck having to query the database every time I need this info to assure security? What about encrypting it and then storing in session state variable (just thought of that one)?
View 5 Replies
Feb 26, 2010
I'm using the DetailView control to display employee details from a specfic company, but it seems when I try to create the query in the data source wizard I'm unable to select the variable for the WHERE clause, only the web pages control components.
The employees are selected through the company name which is entered at the beginning of the page and in turn is used to select the company id.
View 2 Replies
May 17, 2010
By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.
View 10 Replies
Mar 31, 2011
How can I get the value of a hidden field as the value of a query string parameter?
[Code]....
View 2 Replies
May 27, 2010
[Code]....
[Code]....
Get Gridview item template textbox value to string variable?
View 5 Replies
Apr 23, 2010
I have a gridview set up with a button that when clicked I want it to send a unique value to a listview which is set to receive the value in a parameterized SQL query. I forgot how to set the button up in the GUI to take the unique value and put it in a query string and send it to url. I would like to use the GUI just to get more familiar with it. I know this is easy but I gortgot how.
View 5 Replies
Jan 30, 2010
I have a data grid with a lot of information on it - to easily filter the data, I would like to be able to pass parameters to it. My problem is that I do not want the parameters to be required. So if I just put 1 or 2 of them in the query string, I would like for it to return all of the data related to those two parameters.I am using a data grid & stored procedures:My Stored Procedure looks like this:
[Code]...
View 1 Replies
Feb 12, 2010
I have the following ItemTemplate in Repeater1
[code]....
How do I insert the value of ListID into the query string?
View 6 Replies
Jan 13, 2010
I need to know how can I select a gridview row based on a query string data. In my case, the query string will contain the id that exist in the Table related to that grid. Is there a way to do this from the code behind? In other words, if I click a link with that specific query string, can I open the page and tell my grid to select a specific row based on the table row id?
View 1 Replies
Mar 22, 2010
I'm having troubles passing a parameter to a handler in it's query string. I have a gridview with an image column, this column is defined as a TemplateField, as:
<asp:TemplateField
HeaderText="Image">
<ItemTemplate>
<asp:Image
ID="Image1"
runat="server" ImageUrl='~/ImageHandler.ashx?ID=<%# Eval("EmployeeID")%>'
/>
</ItemTemplate>
</asp:TemplateField>
As you can see, the ImageUrl is a call to a handler that receives the EmployeeID in the QueryString, under the name ID. When I run it, the ImageHandler method receives the following query string "ID=<%" instead of "ID=<the result of Eval("EmployeeID")>", and of course, it throws a FormatException when using it as an int to get the EmployeeID. (If I type ImageUrl="~/ImageHandler.ashx?ID=<%# Eval("EmployeeID")%>" (using " instead of ') the compiler returns the error incorrect server tag) The complete markup is:
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Photo] FROM [Employees]">
</asp:SqlDataSource>
<asp:GridView
ID="GridView1"
runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField
DataField="EmployeeID"
HeaderText="ID" SortExpression="EmployeeID"
/>
<asp:BoundField
DataField="FirstName"
HeaderText="FirstName"
SortExpression="FirstName"
/>
<asp:BoundField
DataField="LastName"
HeaderText="LastName" SortExpression="LastName"
/>
<asp:TemplateField
HeaderText="Image">
<ItemTemplate>
<asp:Image
ID="Image1"
runat="server" ImageUrl='~/ImageHandler.ashx?ID=<%# Eval("EmployeeID")%>'
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Could anybody tell me what am I missing here?
Rafael
View 1 Replies
May 7, 2010
I am passing a query string into a new page and want a detailsview to insert whatever comments a user enters
I am getting an error AlbumUID does not accept nulls error.
I thought I passed the query string value to the insert statement but I must have missed something
Here's what I have:
<asp:SqlDataSource ID="SqlDSAddComment" runat="server"
ConnectionString="<%$ ConnectionStrings:MyCDsConnectionStringHome %>"
InsertCommand="INSERT INTO [Comments] ([Comments], [Rating], [AlbumUID]) VALUES (@Comments, @Rating, @AlbumUID)"
[Code]....
View 6 Replies
Sep 19, 2010
I'm tyring to write a simple DetailsView only used for inserting new records that will pre-fill a textbox with a query string value. Here's the DetailsView:
[code]....
All I want to do is set VenueID_FK.Text to = the "VenueID" querry string. I also want the user to be able to see the VenueID number as they are filling out GridView1.
I know this is probably a simple thing, but I am very new to asp.net. I thought I could handle this in the page load event, but when I try something like this
TextBox VenueID_FK = (TextBox)DetailsView1.FindControl("VenueID_FK");
And then follow by setting the Text property programitically. I've accomplished something similar to this on a different page using a FormView, but only for ReadOnly mode and it was handled in the databound event on that page.
I get the error "The name 'DetailsView1' doesn't exist in the current context." when trying to do the above mentioned. When trying the same line in the databound event here, I get the same error.
View 1 Replies
Jan 21, 2010
I'm working on a job seeking website where the job seeker can search for a job , the search box is located in the master page, that's why i passed the keywords as a query string, and then the matching jobs will be displayed in a listview.
the keywords will be taken from two controls: a drop down list which the user can choose the location of the job, and a text box where he can type a keyword.
the select command of the sqlDataSource of the data list is as the following:
[code]....
View 4 Replies
Oct 22, 2010
i put this in a grid so that only one of the rows would have the txt box in it, it works ok ie the txtbox only shows up for the row with 1005 as the ID, but for some reason the query string for each row for the last element in the row, ie an AddToCart image button i have at the end of each row in the grid is not coming out right, ie the query string is missing when the page posts back for all but the last row of the grid which coincidently is the row with the 1005 ID, (the rendered code is shown way down, i apologize for the length of it ) here is the problem line. NOTE when i take the code out of the gridview on row data bound event then the page post back fine and the query string is there, but when i put the code back in the row databound event for the grid then the query string vars and values do not get posted back.
[code]....
View 4 Replies