473,779 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datalist and selectedindex please helpppppppppppp pppppppp

H
data I'm binding to the DataList is information about products in my product database. Perhaps passed in the QueryString to this page is a ProductID. I might want to make the item in the DataList that has the corresponding ProductID selected. In a similar vein, perhaps I want to have newest product selected by default. How can I acheieve this functionality
actuly i use pagin

<%@ Page language="c#" Codebehind="pro duct.aspx.cs" AutoEventWireup ="false" Inherits="nette st1.product" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML><HEAD><t itle>product</title><meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR "><meta content="C#" name="CODE_LANG UAGE"><meta content="JavaSc ript" name="vs_defaul tClientScript"> <meta content="http://schemas.microso ft.com/intellisense/ie5" name="vs_target Schema"><style> A.11pxblue { FONT-SIZE: 11px; COLOR: #00319b; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: underline
A.11pxblue:visi ted { FONT-SIZE: 11px; COLOR: #00319b; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: underline
A.11pxblue:hove r { FONT-SIZE: 11px; COLOR: #00319b; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
</style></HEAD><body MS_POSITIONING= "GridLayout"><f orm id="Form1" method="post" runat="server"> <table width="75%" border="0"><tr> <td>&nbsp
<table><TBODY>< tr><td></td></td><td><asp:dat alist id="Dtl_ProInfo " runat="server" RepeatColumns=" 1" RepeatDirection ="Horizontal">< SeparatorStyle BorderStyle="So lid" BorderColor="Co ntrol"></SeparatorStyle> <ItemTemplate>< table width="87%" border="0"><tr> <td><table width="75%" border="0"><tr> <td>imgdaralist </td></tr><tr><td>clic k here for larger view</td></tr><tr><td>pre next</td></tr></table></td><td><table width="75%" border="0"><tr> <td>img</td></tr><tr><td>Clic k to enlarge image<br></td></tr></table></td><td><table width="100%" border="0"><tr> <td><table width="100%" border="0"><tr> <td>Our Price</td><td><%# DataBinder.Eval (Container.Data Item, "OurPricePerUni t1","{0:c}") %></td></tr><tr><td></td><td>&nbsp;</td></tr><tr><td>Reta il Price:</td><td><%# DataBinder.Eval (Container.Data Item, "RetailPrice"," {0:c}") %></td></tr><tr><td>You save:</td><td><%# DataBinder.Eval (Container.Data Item, "SavedValue","{ 0:c}") %>(<%# DataBinder.Eval (Container.Data Item, "SavedPercentag e","{0:c}") %>%)</td></tr></table></td
Nam
</tr><tr><td><tab le width="75%" border="0"><tr> <td>img</td><td><a>Order Sample o
<%# DataBinder.Eval (Container.Data Item, "Name","{0: c}") %
(<%# DataBinder.Eval (Container.Data Item, "PartNo","{0:c} ") %>)</a></td></tr></table></td></tr><tr><td><tab le width="75%" border="0"><tr> <td>Warranty Protectio
</td></tr><tr><td>More Informatio
</td></tr><tr><td>Revi ews &amp; Ratin
</td></tr><tr><td>Add to Wish Lis
</td></tr></table><br></td></tr></table></td></tr></table></ItemTemplate></asp:datalist><a sp:linkbutton id="Prev" onclick="Page_D ataList" runat="server" Width="105px">< < pre</asp:linkbutton> <asp:linkbutt on id="Next" onclick="Page_D ataList" runat="server" Width="78px">ne xt >></asp:linkbutton> <INPUT id="CurrentPage " type="hidden" value="1" runat="server" NAME="CurrentPa ge"><INPUT id="PageSize" type="hidden" value="1" runat="server" NAME="PageSize" ><INPUT id="TotalSize" type="hidden" runat="server" NAME="TotalSize "></td></TD></tr></table></TD><tr><td>&nbs p;</td></tr><tr><td>&nbs p
<asp:datalist id="DataList3" runat="server"> </asp:datalist></td></tr><tr><td>&nbs p
<asp:datalist id="DataList4" runat="server"> </asp:datalist></td></tr><tr><td>&nbs p
<asp:datalist id="DataList5" runat="server"> </asp:datalist></td></tr><tr><td>&nbs p;</td></tr></TBODY></TABLE></form></body></HTML

how can i show for example row(5) first in datalist

Nov 18 '05 #1
1 1671
This is how you can implement it. Here is an example of the
menucontrol.asc x.cs on IBuySpy Portal.for More Details
http://www.ibuyspy.com/IBS_Store/Sou...4RegardsAshish M
Bhonkiya<%@ Control Language="C#" %><%@ Import
Namespace="Syst em.Data.SqlClie nt" %><%@ OutputCache Duration="3600"
VaryByParam="se lection" %><script runat="server">
//*************** *************** *************** ********** // // The
Page_Load event on this page is used to obtain // from a database a list
of all product categories // and databind it to an asp:datalist control.
// // To optimize performance, this user control is output // cached
(varying based on the categoryId and selection // passed through the
querystring. //
//*************** *************** *************** ********** void
Page_Load(Objec t sender, EventArgs e) { // Set the curent
selection of list String selectionId = Request.Params["selection"];
if (selectionId != null) { MyList.Selected Index =
Int32.Parse(sel ectionId); } // Obtain list of menu categories
and databind to list control IBuySpy.Product sDB products = new
IBuySpy.Product sDB(); MyList.DataSour ce =
products.GetPro ductCategories( );
List.DataBind() ; }</script><table cellspacing="0" cellpadding="0"
width="145" border="0"> <tr valign="top"> <td colspan="2">
<a href="default.a spx"><img src="images/logo.gif" border="0"></a>
</td> </tr> <tr valign="top"> <td colspan="2">
<asp:DataList id="MyList" runat="server" cellpadding="3" cellspacing="0"
width="145" SelectedItemSty le-BackColor="dimg ray" EnableViewState ="false">
<ItemTemplate > <asp:HyperLin k cssclass="MenuU nselected"
id="HyperLink1 " Text='<%# DataBinder.Eval (Container.Data Item,
"CategoryNa me") %>' NavigateUrl='<% # "productslist.a spx?CategoryID= " +
DataBinder.Eval (Container.Data Item, "CategoryID ") + "&selection =" +
Container.ItemI ndex %>' runat="server" /> </ItemTemplate>
<SelectedItemTe mplate> <asp:HyperLin k
cssclass="MenuS elected" id="HyperLink2 " Text='<%#
DataBinder.Eval (Container.Data Item, "CategoryNa me") %>' NavigateUrl='<% #
"productslist.a spx?CategoryID= " + DataBinder.Eval (Container.Data Item,
"CategoryID ") + "&selection =" + Container.ItemI ndex %>' runat="server" />
</SelectedItemTem plate> </asp:DataList> </td> </tr>
<tr> <td width="10"> </td> <td>
<br><br><br><br ><br><br> <a href="docs/docs.htm" target="_blank"
class="SiteLink ">IBuySpy Store<br>Docume ntation</a> </td>
</tr></table>
Nov 18 '05 #2

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

Similar topics

2
3099
by: David D. McCrory | last post by:
This is the second post for this question....please help!! This is a fairly simple request....I am looking for some help.... I want to set the SelectedIndex of a DataList control to equal a specific record in the database. What is the easiest way to accomplish this?? Thanks, David D. McCrory
1
4708
by: wsyeager36 | last post by:
I have a datagrid inside a datalist. The datalist shows parent info and the datagrid shows the child info for that parent. There is a checkbox on each row of the child datagrid. Also inside the datalist is a radiobuttonlist. When this radiobuttonlist is checked, I would like it to iterate thru each row on the child grid and either select or deselct the checkboxes (which are on each row of the child datagrid). In addition, the user can also check...
1
2153
by: Neil Jarman | last post by:
Hi, I'm new to this today, and I've got some test code (see below.) The data loads fine. I can't understand why any of the events fire. Once the page loads, clicking on thew button from the ItemTemplate does not fire the OnItemCommand event. It just fires a page reload - as a postback. I guess I'm missing something really obvious and important here?
1
11953
by: Gary Frank | last post by:
I added a couple of labels and a button to a Datalist control called "dlSignIn" by adding them to the Item template. The labels are bound to a dataset column. Program code gets executed in the dlSignIn_SelectedIndexChanged subroutine when I click the button in the datalist. And the dlSignIn.SelectedIndex property has the correct index for the Datalist row that was selected. Now I would like to access the values in the labels of that...
4
15998
by: Chris Kettenbach | last post by:
Good morning all, I am sure this has been asked but I did not see anything. I have a datalist control. In the edititemtemplate I have a dropdownlist. I know on the itemdatabound event is where I can set the dropdownlist selectedindex. How do I set the correct value? private void lstDegrees_ItemDataBound(object sender, DataListItemEventArgs e) {
1
2943
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to call databind (sender.DataBind(); in NeedList_ItemCommand method). The error message is at the bottom of this message (System.NullReferenceException) Can anyone else see anything wrong with this? (I've included all relevant code, stored...
0
3948
by: Isz | last post by:
PROBLEM: This problem is related to the postback and handling events correctly. BACKGROUND: I have a datalist which acts as a tabbes list with horizontal layout. This datalist is bound to a strogly typed collection I called TabCollection which is a collevtion of items called tab. Each tab is as follows:
0
1649
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set in the Page_Load. The inner DataList has its DataSource set in the ascx file as: <asp:DataList ID="PageList" runat="server" CellPadding="3" CellSpacing="0" DataSource='<%#...
1
3163
by: Jules | last post by:
We have a problem setting, actually resetting, the SelectedItemTemplate of a DataList control. Below is the ObjectDataSource and the DataList in .ASPX: <asp:ObjectDataSource ID="mySource" runat="server" SelectMethod="GetStageUsage" TypeName="SomeController"> </asp:ObjectDataSource> <asp:DataList ID="dl" runat="server" DataSourceID="mySource" DataKeyField="ID" OnItemCommand="dl_ItemCommand">
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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
10302
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...
1
10071
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,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7478
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...
1
4036
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
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
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.