473,805 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview Selection

Is it possible to select an item on a gridview by clicking on it and
then being able to click a link for example that says EditOrder in a
treeview and have the EditOrder page open up viewing what you selected
in the gridview? My EditOrder link is in a sitemap so I don't know if
it is possible becuase you would almost have to pass a variable to the
sitemap. What would be the easiest way to accomplish it?

Feb 21 '06 #1
1 5114
The best approach would be be to add the Edit link in the GridView
rather than in the TreeView. Adding values to the query string is easy
inside the GridView, just add a HyperLinkField and populate the
DataNavigateURL Fields and DataNavigateUrl FormatString. However, if you
are stuck using a TreeView to navigate to the Edit Page, you have to
update the URL programatically (someone correct me if I'm wrong about
this). Here's a form with a GridView control and a TreeView.

<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView" runat="server"
DataSourceID="S iteMapDataSourc e">
</asp:TreeView>

<asp:GridView ID="GridView" runat="server"
DataSourceID="S qlDataSource"
OnSelectedIndex Changed="GridVi ew_SelectedInde xChanged">
<Columns>
<asp:CommandFie ld ShowSelectButto n="True" />
</Columns>
<SelectedRowSty le BackColor="#FFF FC0" />
</asp:GridView>

<asp:SqlDataSou rce ID="SqlDataSour ce" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:pubsConnecti onString
%>"
SelectCommand=" SELECT [ord_num], [ord_date], [qty] FROM
[sales]">
</asp:SqlDataSour ce>
</div>
<asp:SiteMapDat aSource ID="SiteMapData Source" runat="server" />
</form>

And here's the Web.Sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microso ft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title="Home">
<siteMapNode url="~/EditOrder.aspx" title="Edit Order" />
</siteMapNode>
</siteMap>

To set the querystring on the EditOrder link update it when the
selected item on the grid changes:

protected void GridView_Select edIndexChanged( object source, EventArgs
e)
{
GridViewRow row = GridView.Select edRow;
string order_number = row.Cells[1].Text;

TreeNode tn = TreeView.FindNo de(Server.HtmlE ncode("Home/Edit
Order"));
tn.NavigateUrl = string.Format(" ~/EditOrder.aspx? ord_num={0}",
order_number);
}

You can improve on the code to get the order_number and find the
TreeNode, but the key is updating the NavigateURL each time the
selected item changes. It's a little ugly, but if you need to use a
TreeView bound to a sitemap file it may be your only option.

-Carl

Feb 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6998
by: mateo | last post by:
Hello, I have a GridView inside which i want to show 3 dropdownList (one for each Column). So i've created 3 TemplateField Continent Country City
1
1408
by: bill tie | last post by:
I have two dropDownLists A and B outside a gridView. A selection made in ddlA causes ddlB to be populated with data from the database. The gridView is populated with data according to a selection in ddlB. ddlA --> ddlB --> gridView When a user selects an item in ddlA, I want (a) the ddlB to be populated automatically
3
10161
by: tarscher | last post by:
Hi all, I have a gridview populated with data coming from a dataset (created via the wizard). The data shown in the gridview is dependent on the the choice of a control (dropdown with autopostback enabled). When I load the page for the first time I the gridview is empty. When I select something in the dropdownlist the gridview is populated correctly. I guess this has something to do with the fact that the first time no data from the...
10
6696
by: Carlos | last post by:
Hi all, I have a form with an input radio control in a template field. When the user selects an option, and press a button the selection disappears.. I would like the selection to persist after the button makes the postback, I tried using the findcontrol but it returns null, and do not know how to make sure that the radio selected persist after the button action makes the postback.
4
4222
by: Randy Smith | last post by:
Hi, I would like to limit my user selection to only one row in the GridView at a time. Is there any way to set this? TIA, Randy
0
3043
by: New2ASP | last post by:
Thanks everyone in advance for your help. I am fairly new to web development but an experienced window-based developer. Here's the structure of my Gridview Column 1 : Checkbox with SelectAll Checkbox Header Column 2-9: BoundField Column 10: img field If the user select one checkbox item, it will open up another gridview (multiple selection does nothing). If select a row item, it will open a different aspx page. If select...
0
4669
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
0
1607
geo039
by: geo039 | last post by:
I have a usercontrol with textboxes. Most of which refer to a gridview on selection. A user clicks a looking glass and a gridview appears to select items (like a dropdown). The page loads with databound to each textbox from the DB. They can change fields and update. The problem I'm having is one textbox with gridview populates another based on selected value. If the textbox is not bound it works fine - make a selection go to the next box and...
0
1202
by: Rasika WIJAYARATNE | last post by:
Hi everyone, I have two grid-views and I am trying to populate the data on gv2 based on the selection in gv1. However when a row is selected in gv1, it doesn't populate the gv2 with data. I have ensured that the ObjectDataSource (ods2) for gv2 works and load data correctly by specifying hardcoded primary key value within a Paramater. Anyone know what is a miss here to prevent gv2 from loading it's data???
13
3522
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show allowing the user to make a selection from the popup window. I have enabled AJAX extensions and have a working sample outside of a gridview. However, when I click in the textbox of a gridview row, all I see is a really small square instead of the...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10356
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.