473,215 Members | 1,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,215 software developers and data experts.

datalist and selectedindex please helpppppppppppppppppppp

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="product.aspx.cs" AutoEventWireup="false" Inherits="nettest1.product" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML><HEAD><title>product</title><meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"><meta content="C#" name="CODE_LANGUAGE"><meta content="JavaScript" name="vs_defaultClientScript"><meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"><style>A.11pxblue { FONT-SIZE: 11px; COLOR: #00319b; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: underline
A.11pxblue:visited { FONT-SIZE: 11px; COLOR: #00319b; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: underline
A.11pxblue:hover { FONT-SIZE: 11px; COLOR: #00319b; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
</style></HEAD><body MS_POSITIONING="GridLayout"><form id="Form1" method="post" runat="server"><table width="75%" border="0"><tr><td>&nbsp
<table><TBODY><tr><td></td></td><td><asp:datalist id="Dtl_ProInfo" runat="server" RepeatColumns="1" RepeatDirection="Horizontal"><SeparatorStyle BorderStyle="Solid" BorderColor="Control"></SeparatorStyle><ItemTemplate><table width="87%" border="0"><tr><td><table width="75%" border="0"><tr><td>imgdaralist</td></tr><tr><td>click 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>Click 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.DataItem, "OurPricePerUnit1","{0:c}") %></td></tr><tr><td></td><td>&nbsp;</td></tr><tr><td>Retail Price:</td><td><%# DataBinder.Eval(Container.DataItem, "RetailPrice","{0:c}") %></td></tr><tr><td>You save:</td><td><%# DataBinder.Eval(Container.DataItem, "SavedValue","{0:c}") %>(<%# DataBinder.Eval(Container.DataItem, "SavedPercentage","{0:c}") %>%)</td></tr></table></td
</tr><tr><td><table width="75%" border="0"><tr><td>img</td><td><a>Order Sample o
<%# DataBinder.Eval(Container.DataItem, "Name","{0:c}") %
(<%# DataBinder.Eval(Container.DataItem, "PartNo","{0:c}") %>)</a></td></tr></table></td></tr><tr><td><table width="75%" border="0"><tr><td>Warranty Protectio
</td></tr><tr><td>More Informatio
</td></tr><tr><td>Reviews &amp; Ratin
</td></tr><tr><td>Add to Wish Lis
</td></tr></table><br></td></tr></table></td></tr></table></ItemTemplate></asp:datalist><asp:linkbutton id="Prev" onclick="Page_DataList" runat="server" Width="105px"><< pre</asp:linkbutton><asp:linkbutton id="Next" onclick="Page_DataList" runat="server" Width="78px">next >></asp:linkbutton><INPUT id="CurrentPage" type="hidden" value="1" runat="server" NAME="CurrentPage"><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>&nbsp;</td></tr><tr><td>&nbsp
<asp:datalist id="DataList3" runat="server"></asp:datalist></td></tr><tr><td>&nbsp
<asp:datalist id="DataList4" runat="server"></asp:datalist></td></tr><tr><td>&nbsp
<asp:datalist id="DataList5" runat="server"></asp:datalist></td></tr><tr><td>&nbsp;</td></tr></TBODY></TABLE></form></body></HTML

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

Nov 18 '05 #1
1 1620
This is how you can implement it. Here is an example of the
menucontrol.ascx.cs on IBuySpy Portal.for More Details
http://www.ibuyspy.com/IBS_Store/Sou...4RegardsAshish M
Bhonkiya<%@ Control Language="C#" %><%@ Import
Namespace="System.Data.SqlClient" %><%@ OutputCache Duration="3600"
VaryByParam="selection" %><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(Object sender, EventArgs e) { // Set the curent
selection of list String selectionId = Request.Params["selection"];
if (selectionId != null) { MyList.SelectedIndex =
Int32.Parse(selectionId); } // Obtain list of menu categories
and databind to list control IBuySpy.ProductsDB products = new
IBuySpy.ProductsDB(); MyList.DataSource =
List.DataBind(); }</script><table cellspacing="0" cellpadding="0"
width="145" border="0"> <tr valign="top"> <td colspan="2">
<a href="default.aspx"><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" SelectedItemStyle-BackColor="dimgray" EnableViewState="false">
<ItemTemplate> <asp:HyperLink cssclass="MenuUnselected"
id="HyperLink1" Text='<%# DataBinder.Eval(Container.DataItem,
"CategoryName") %>' NavigateUrl='<%# "productslist.aspx?CategoryID=" +
DataBinder.Eval(Container.DataItem, "CategoryID") + "&selection=" +
Container.ItemIndex %>' runat="server" /> </ItemTemplate>
<SelectedItemTemplate> <asp:HyperLink
cssclass="MenuSelected" id="HyperLink2" Text='<%#
DataBinder.Eval(Container.DataItem, "CategoryName") %>' NavigateUrl='<%#
"productslist.aspx?CategoryID=" + DataBinder.Eval(Container.DataItem,
"CategoryID") + "&selection=" + Container.ItemIndex %>' runat="server" />
</SelectedItemTemplate> </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>Documentation</a> </td>
Nov 18 '05 #2

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

Similar topics

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...
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...
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...
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...
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...
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...
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...
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...
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"...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.