Ascx
|
<style type="text/css">
.ContentClass
{
background-color:Aqua;
color:Blue;
font-weight:bold;
font-size:15px;
font-family:Calibri;
}
</style>
<table width="100%" cellpadding="0" cellspacing="0" class="ContentClass">
<tr>
<td>
<asp:BulletedList ID="nlCountry" runat="server" DataTextField="Title"
DataValueField="ID" DisplayMode="LinkButton" BulletStyle="Numbered"
onclick="nlCountry_Click">
</td>
</tr>
</table>
|
Ascx.cs
|
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Security;
namespace NumberedList.NumberedList
{
public partial class NumberedListUserControl : UserControl
{
protected
void Page_Load(object
sender, EventArgs e)
{
if
(!IsPostBack)
{
getData();
}
}
public
void getData()
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPQuery
sQuery = new SPQuery();
sQuery.Query = "<OrderBy><FieldRef
Name=\"Title\" /></OrderBy>";
SPListItemCollection
myColl = SPContext.Current.Web.Lists["lst_Country"].GetItems(sQuery);
if
(myColl.Count > 0)
{
nlCountry.DataSource =
myColl.GetDataTable();
nlCountry.DataBind();
}
});
}
protected
void nlCountry_Click(object
sender, BulletedListEventArgs e)
{
ListItem
li = nlCountry.Items[e.Index];
Response.Redirect(SPContext.Current.Web.Url + "/Lists/lst_Country/DispForm.aspx?ID="
+ li.Value + "&Source=" +
Page.Request.Url);
}
}
}
|
Tuesday, February 12, 2013
Adding Hyperlink to Asp.Net Bulleted List using SharePoint Data Without a single line of Loop
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment