Creating Dynamic Controls in Gridview Columns

I need a gridview that needs to show information about a product and show information about this product. In the gridview I also want to run a count of how many products there are. To do this I have used an sqldatasource to bind the select information that is about the product and then in the Gridview Databound event i use another sqldatasource to query the Count for each product and then attach to the last column. This all works fine and gets me the results. idont know if it is effecient but it works. I now want the count column to be clickable(ex..Button,linkbutton). When i click the count it will be bring me to a new page that will show different detail about the product. Such as the number sold during this month or today or to which customer. I can create a link button that will show the letter as the text its just i can't figure a way to keep the product in that rows product ID so that I can use it to query on the new page. I may be going about this all wrong. Any ideas would be great. Can I do this with one sqldatasource? Can i make the linkbutton kick off the gridview onselected change event so that I can get the values there. Thanks any help is apperciated. 

 

0
laustin01
7/18/2007 8:53:25 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
611 Views

Similar Articles

[PageSpeed] 9

Do you have to using two sqldatasource?


from Villa El Salvador for world!
0
Javier
7/19/2007 5:07:37 AM

I dont know anyother way of bring back the second query? For example I have a query that says "Select * From ProductsTable Where productID ='?'", then the second sqldatasource uses "Select Count(Products) From ProductsTable Where SoldDate < Today and SoldDate > two days ago". This is a hypothetical query because the actual one has multiple joins. Is there another way to do this without using two? I thought maybe I could bring the values back from both tables and then push them into a dataset or datatable then databind it to a datagrid but that would still leave me with my problem of not being able to turn the count field into a link to another page where it would carry that rows values to the next page for me to use? Any ideas on that? 

0
laustin01
7/19/2007 12:58:32 PM

Just a quick update I stumbled upon using subqueries to get the results I wanted from one query which means one sqldatasource. Now I guess the question is how do I make the column a hyperlink or just clickable and send me to another page and bring the data from that row with me across pages. Is there an event for the click and if so how do I use the session state to retain the values. Thanks!

0
laustin01
7/19/2007 4:16:54 PM

Just a quick update I stumbled upon using subqueries to get the results I wanted from one query which means one sqldatasource. Now I guess the question is how do I make the column a hyperlink or just clickable and send me to another page and bring the data from that row with me across pages. Is there an event for the click and if so how do I use the session state to retain the values. Thanks!

0
laustin01
7/19/2007 4:22:53 PM
Reply:

Similar Artilces:

User Control controls not created when dynamically creating user control
  Have created a user control for displaying and editing a dynamically number of values. The user control contains two labels and an edit box. When dynamically loading the user control I get an error when the control itself tries to change setting on the fields within the user control.   Why doesnt this work? It works okay if I dont load it dynamically but create a user-control-instance in the aspx-page but thats no solution.   Thankyou!     Here is my code:   ucDataValue.ascx   <%@ Control Language="C#" AutoEventWireup="true&...

Gridview and dynamically created controls
Hello, I have a gridview with a lot of rows. This means I can't create the the correct controls (like dropdowns) at once but I have to create them once the user wants to edit a row. Anyhow, this is an example of how I create a dropdown:  Dim lstPersCat As New DropDownList lstPersCat.ID = "lstPersCat" Dim strUserGroups(10) As String strUserGroups = retUserGroups(CType(gvResults.Rows(e.NewEditIndex).Cells(9).Controls(0), TextBox).Text.ToString) For i As Integer = 0 To strUserGroups.Length - 1 If Len(strUserGroups(...

create and add controls dynamically to dynamically created Table Control
How can i create web server Table control dynamically with vary number of  rows and columns, and  then adding  further  other controls(like  dropdown, Text box etc.)  randomly to the specific created Table Cells. First of all you should use PlaceHolder control to add Table control to it:<asp:PlaceHolder id="PH" runat="server"></asp:PlaceHolder>Code Behinde:Table t = new Table();TableRow tr = new TableRow();TableCell td = new TableCell();//td.Text = "Hello, I am a TD";// Here well create TextBox and add it to TDTextBox txt = new TextBox();tx...

Create Dynamic Dropdownlist Controls / How to Create Dynamic Dropdownlist Controls
Hi,    This might be useful for someone who strucks with create dynamic dropdownlist/ controls. In ASP.Net is page is stateless. when you are creating the dynamic dropdownlist control following issues you might be facing, 1. After loaded the control, on selected index changed event the control will be disappear. 2. The selectedIndexChanged raised event might not be fired when selection of Dropdownlist. 3. Locate the exact dropdownlist which you created dynamically. 4.Placing this dynamic controls in exact location in the page. Solution: You have to re-create the con...

postback from dynamic controls to create more dynamic controls
Hi, Could any one help me?  I have a masterpage with dynamically created list boxes.  When the user selects an item from the listbox the selected value will be used to dynamically create a set of controls in the contentplaceholder.  The problem i have is that the item selected from the list box is posted back and i do not know what the selected item is until the life cycle is complete.  During the post back is there a way to findout which listbox control performed a post back and its value before i get to the init part of the content page where i woul...

Dynamically create controls in GridView template column
Hi,this is my first post so please be nice :)I have a situation where I'm loading GridView from XML data source and I need to dynamically create a TABLE control inside grids template column.One of table's columns has an editable TextBox, so there could be unknown number of rows in a gridview and unknown number of rows in each table.At the moment I'm creating those tables inside  GridView_RowDataBound event and all works fine.Problem is that when user clicks in "Update" button table controls are gone because they are dynamically created.My question is how can I crea...

Bubbling Events on Dynamically created controls that are on dynamically created user-controls on a module!! HELP MAH PUHLEASE!
I may be cross posting this question, but I am really going to go crazy.. Please help if you can!I think I am going to go mad. If anyone can help me with this small issue, I will build an idol in your image made of clay, and have nubile maidens dance in front of it in worship!!!!I have a module. Let's call it Module-1Module-1 Connects to a database and gets a list of items.Module-1 Then creates on the fly a number of buttons that represent that list of items.Each button when clicked dynamically creates a web-user control. Let's pull out 1 button, and 1 usercontrol and call them Button-1 and ...

Loading controls dynamically based of previously dynamically created control
Hi All, Heres the deal. I have a hierarchal or tree structure of data that needs to be represented in dropdownlists (ddl). The root is a single ddl and the items in the ddl are children of the root. When a child is selected I need to add another ddl to the control collection with it's children as listitems. Its like dropdownlist chaining without knowing the order of the dropdownlists. Now I know I can use the Page.OnInit method to add the ddl, but since viewstate is not loaded until after OnInit is called I don't have access to the selected child. Right know I am getting around this by u...

Dynamically creating controls in a Table control
Hi I'm using a Table control to create a table in a Webform, however I need to be able to create additional controls within certain cells for instance an ImageButton where I can then build an event handler for each one I dynamically create. How do I do this, I've been trying add the control to the Controls collection of either the Page or the Table - all with poor results. Normally I'd add a control into a place holder, but again that's something that I'd need to dynamically create also in each cell I suppose...? Please help! Thanks in advance. get the HtmlTableCell e.g. H...

remove a gridview column dynamically, removes controls in template columns
I have a interface with a treeview and a gridview. The gridview has two templatefields that handles insert/update/deletes. The gridview is handling editing of different tables so I create the other columns in the gridview dynamically as boundfields. The user selects the table to edit in the treeview. The problem I am having happens when the user selects a table to edit the second time. The code that executes removes all bound fields, (dynamically added when user selected the first table in the treeview), but not the two template fields, and then adds boundfields specifi...

Dynamic Slave Controls
I am working a solution to enhance slave controls. I have created a proof of concept based on the 2.04 code base that shows how to load slave controls without switching to the admin view. I have included a sample module that contains 3 view controls. Each control has a row of buttons that can be used to load one of the other 2 controls. (and no I am not using panels.) The default control has a drop down of other instances of the dynamic control that exist on the current tab. Using the module communicator you can raise an event from one control that tells another instance of the module what c...

Adding dynamically created controls to Wizard control.
Thanks for showing interest in my post.I am dynamically creating controls on a specific step in my wizard and im wondering if its possible to add these controls to the wizard, not the form?currently im doing the following to add the textboxes to the Form...form.controls.add(txtbox) places the controls under the wizard, which makes sense to me.wizard.controls.add(txtbox) doesn't seem to be working out for me.any ideas? thanks all. Hi,    you know, a wizard control usually  has several step, if you add a control like wizard.controls.add(txtbox), how could the page determ...

Loop and dynamically create control from ascx control
 I tryed both solutions : 1) ASPX code behind :For Each ...    SqlDataSource1.SelectCommand = "select [note] from [NOTES] where [id_note]='" & myVar & "'"      // myVar is different for each loop, I checked that -_-    Dim myControl = Page.LoadControl("tata.ascx")    panel.ContentContainer.Controls.Add(myControl)Next      ASCX :    <asp:TextBox ID="textbox1" runat="server" Text='<%# DataBinder.Eval(Container,...

Dynamically Creating vcr-control against datawindow-control
Hi all, I've got following problem: On a DW-control, i want to have a uo-function of_set_vcr(true/false) which, when param=true automatically creates vcr-control on left side of dw-control. I allready discovered i could do something like that by using something like this: window.openuserobject(iuo_vcr,"uo_vcr",x,y) but this works fine when you can create object directly onto window. In my case i've a window with a tab-control(with 2 tabpages) onto it. A dw-control is included on tabpage 2. So when calling of_set_vcr(true), i want to appear uo_vcr on...

Web resources about - Creating Dynamic Controls in Gridview Columns - asp.net.presentation-controls

Londonistan: How Britain is Creating a Terror State Within - Wikipedia, the free encyclopedia
The book encompasses a critique of multiculturalism , alleged weak policing, cultural relativism , and what Phillips calls a 'victim culture'. ...

Facebook’s Matt Kelly Describes Process Of Creating Plugin For WordPress
The plugin for WordPress launched by Facebook in June has been downloaded more than 180,000 times, and Engineer, Developer Relations Matt Kelly ...

Creating Online Ads that Drive Brand Awareness
New research shows how the creative elements of online ads impact brand awareness.

Bug - Creating a Video.Watches Action stopped working - Facebook-Entwickler
Since today executing a POST on a me/video.wacthes endpoints no longer works, it was working around 10 hours ago since then the call always returns ...

Facebook Creating Fourth-Party Privacy Rules for Facebook Connect Widget & Plugin Developers
In a recently-written post on the Facebook Developers Wiki, Facebook had added new rules for information sharing between websites that have implemented ...

The Obama campaign won by creating their own Facebook, with unique features for political campaigns.
... seen as too dangerous to nominate someone who is so thoroughly narcissistic, arrogant and dishonest. The Obama campaign won basically by creating ...

Creating A Great Startup Culture
... with any Bay Area startup these days (ping pong, beer on tap, catered lunches and Macbook Airs) – though these things are, of course, Creating ...

WIRED Creating the Nebula for iPad on the iTunes App Store
Get WIRED Creating the Nebula on the App Store. See screenshots and ratings, and read customer reviews.

Nets of freedom creating mesh networks 03.07.2013 - Flickr - Photo Sharing!
Explore Strelka Institute photo's photos on Flickr. Strelka Institute photo has uploaded 14526 photos to Flickr.

Creating the incorrigible Cartman - YouTube
"South Park" creators Trey Parker and Matt Stone were big fans of "All in the Family," a 1970s CBS sitcom. Perhaps this is why their most incorrigible ...

Resources last updated: 11/29/2015 3:31:32 PM