Just another WordPress.com weblog

sample

<telerik:RadAjaxManager ID=”RadAjaxManager1″ runat=”server” RequestQueueSize=”5″>          <AjaxSettings>              <telerik:AjaxSetting AjaxControlID=”timer”>                  <UpdatedControls>                      <telerik:AjaxUpdatedControl ControlID=”RadGrid1″ LoadingPanelID=”RadAjaxLoadingPanel1″ />                      <telerik:AjaxUpdatedControl ControlID=”Label1″ />                      <telerik:AjaxUpdatedControl ControlID=”Label2″ />                  </UpdatedControls>              </telerik:AjaxSetting>              <telerik:AjaxSetting AjaxControlID=”RadGrid1″>                  <UpdatedControls>                      <telerik:AjaxUpdatedControl ControlID=”RadGrid1″ LoadingPanelID=”RadAjaxLoadingPanel1″ />                      <telerik:AjaxUpdatedControl ControlID=”Label1″ />                  </UpdatedControls>              </telerik:AjaxSetting>          </AjaxSettings>      </telerik:RadAjaxManager>     <asp:Timer ID=”timer” runat=”server” Interval=”5000″ ontick=”timer_Tick”></asp:Timer>         <asp:Label ID=”Label1″ runat=”server” Text=”Label”></asp:Label>              <asp:Label ID=”Label2″ runat=”server” Text=”Label”></asp:Label>     <telerik:RadAjaxLoadingPanel runat=”server” ID=”RadAjaxLoadingPanel1″ BackColor=”LightSeaGreen” >     <div style=”width:100%;height:100%”></div>     </telerik:RadAjaxLoadingPanel>              <div style=”width:1000px”>         <telerik:RadGrid ID=”RadGrid1″ runat=”server” Width=”100%” AllowPaging=”true” AllowSorting=”true” AutoGenerateColumns=”false”  OnPageIndexChanged=”RadGrid1_PageIndexChanged”              OnPageSizeChanged=”RadGrid1_PageSizeChanged”             OnSortCommand=”RadGrid1_SortCommand”                  AllowFilteringByColumn=”true” OnItemDataBound=”RadGrid1_ItemDataBound”>             <MasterTableView AutoGenerateColumns=”false” AllowFilteringByColumn=”True” ShowFooter=”True”>                 <Columns>                     <telerik:GridMaskedColumn DataField=”CustomerID” HeaderText=”CustomerID” FilterControlWidth=”50px”                         CurrentFilterFunction=”EqualTo” ShowFilterIcon=”true” UniqueName=”CustomerID”>                     </telerik:GridMaskedColumn>                     <telerik:GridBoundColumn FilterControlWidth=”120px” DataField=”CompanyName” HeaderText=”CompanyName”                         CurrentFilterFunction=”Contains” ShowFilterIcon=”true”>                     </telerik:GridBoundColumn>                     <telerik:GridBoundColumn FilterControlWidth=”120px” DataField=”ContactTitle” HeaderText=”ContactTitle”                         AutoPostBackOnFilter=”true” CurrentFilterFunction=”Contains” ShowFilterIcon=”true”>                     </telerik:GridBoundColumn>                     <telerik:GridBoundColumn FilterControlWidth=”120px” DataField=”Address” HeaderText=”Address”                         AutoPostBackOnFilter=”true” CurrentFilterFunction=”Contains” ShowFilterIcon=”true”>                     </telerik:GridBoundColumn>                     <telerik:GridBoundColumn FilterControlWidth=”120px” DataField=”Phone” HeaderText=”Phone”                         AutoPostBackOnFilter=”true” CurrentFilterFunction=”Contains” ShowFilterIcon=”true”>                     </telerik:GridBoundColumn>                 </Columns>             </MasterTableView>         </telerik:RadGrid>         </div>

——————————————–  protected void Page_Load(object sender, EventArgs e)         {             if (!IsPostBack)             {                 LoadDataForRadGrid1();                 Label1.Text = DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss tt”);             }              }

private void LoadDataForRadGrid1()         {             DataTable Source = new DataTable();             Source=(DataTable)Cache["MyDataSet"];             if (Source == null)             {                 RadGrid1.DataSource = GetDataTable();                 Label2.Text = “dt”;             }             else             {                 RadGrid1.DataSource = Source;                 Label2.Text = “cache”;             }         }

public DataTable GetDataTable()         {

DataTable dt = new DataTable();             DataColumn dc = new DataColumn();             dc.ColumnName = “CustomerID”;             dc.DataType = typeof(string);             dt.Columns.Add(dc);

dc = new DataColumn();             dc.ColumnName = “CompanyName”;             dc.DataType = typeof(string);             dt.Columns.Add(dc);

dc = new DataColumn();             dc.ColumnName = “ContactTitle”;             dc.DataType = typeof(string);             dt.Columns.Add(dc);

dc = new DataColumn();             dc.ColumnName = “Address”;             dc.DataType = typeof(string);             dt.Columns.Add(dc);

dc = new DataColumn();             dc.ColumnName = “Phone”;             dc.DataType = typeof(string);

dt.Columns.Add(dc);             int i;

for (i = 0; i < 300; i++)             {                 dt.Rows.Add(new object[] { “1″+i, “Max”+i, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com“, “My Phone is 123456789″ });                             }             Cache["MyDataSet"] = dt;             TimeSpan freshness = new TimeSpan(0, 0, 0, 60);             DateTime now = DateTime.Now;             Response.Cache.SetExpires(now.Add(freshness));             Response.Cache.SetMaxAge(freshness);             Response.Cache.SetCacheability(HttpCacheability.Server);             Response.Cache.SetValidUntilExpires(true);             return dt;

}

protected void RadGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)         {             LoadDataForRadGrid1();         }         protected void RadGrid1_PageSizeChanged(object sender, Telerik.Web.UI.GridPageSizeChangedEventArgs e)         {             LoadDataForRadGrid1();         }         protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)         {             LoadDataForRadGrid1();         }

//protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)         //{         //    if (e.CommandName == RadGrid.FilterCommandName)         //    {         //        LoadDataForRadGrid1();         //        //Pair filterPair = (Pair)e.CommandArgument;         //        ////gridMessage1 = “Current Filter function: ‘” + filterPair.First + “‘ for column ‘” + filterPair.Second + “‘”;         //        //TextBox filterBox = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].Controls[0] as TextBox;         //        ////gridMessage2 = “<br> Entered pattern for search: ” + filterBox.Text;         //        //LoadDataForRadGrid1();         //        //RadGrid1.MasterTableView.FilterExpression = “([" + filterPair.Second + "] LIKE \’%” + filterBox.Text+”%\’) “;         //        //GridColumn column = RadGrid1.MasterTableView.GetColumnSafe(filterPair.Second.ToString());

//        //column.CurrentFilterFunction = GridKnownFunction.Contains;         //        //column.CurrentFilterValue = filterBox.Text;         //    }         //}         //private string gridMessage1 = null, gridMessage2 = null;         //protected void RadGrid1_DataBound(object sender, EventArgs e)         //{         //    if (!string.IsNullOrEmpty(gridMessage1))         //    {         //        //Current Filter function: ‘StartsWith’ for column ‘CompanyName’         //        //Entered pattern for search: a          //        //DisplayMessage(gridMessage1);         //        //DisplayMessage(gridMessage2);

//        //            RadGrid1.MasterTableView.FilterExpression = “([ColumeUniqueName] = ” + ViewState(“ID”) + “)”;         //        //RadGrid1.Rebind();

//    }         //}         //private void DisplayMessage(string text)         //{         //    //RadGrid1.Controls.Add(new LiteralControl(string.Format(“<span style=’color:red’>{0}</span>”, text)));         //}

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)         {             if (e.Item is GridPagerItem)             {                 RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl(“PageSizeComboBox”);                 PageSizeCombo.Items.Clear();

PageSizeCombo.Items.Add(new RadComboBoxItem(“10″));                 PageSizeCombo.FindItemByText(“10″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.Items.Add(new RadComboBoxItem(“20″));                 PageSizeCombo.FindItemByText(“20″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.Items.Add(new RadComboBoxItem(“30″));                 PageSizeCombo.FindItemByText(“30″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.Items.Add(new RadComboBoxItem(“40″));                 PageSizeCombo.FindItemByText(“40″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.Items.Add(new RadComboBoxItem(“50″));                 PageSizeCombo.FindItemByText(“50″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.Items.Add(new RadComboBoxItem(“60″));                 PageSizeCombo.FindItemByText(“60″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.Items.Add(new RadComboBoxItem(“70″));                 PageSizeCombo.FindItemByText(“70″).Attributes.Add(“ownerTableViewId”, RadGrid1.MasterTableView.ClientID);

PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;             }         }         protected void timer_Tick(object sender, EventArgs e)         {             LoadDataForRadGrid1();             Label1.Text = DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss tt”);         }

test 1

<%@ Control Language=”C#” AutoEventWireup=”true” CodeBehind=”WebUserControl1.ascx.cs” Inherits=”WebApplicationRepeater.WebUserControl1″ %>

<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css&#8221; />
<link rel=”stylesheet” href=”http://jqueryui.com/resources/demos/style.css&#8221; />

<%– <link href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css&#8221; rel=”stylesheet” type=”text/css”/>–%>

<script src=”http://code.jquery.com/jquery-1.9.1.js&#8221; type=”text/javascript” language=”javascript”></script>
<script src=”http://code.jquery.com/ui/1.10.4/jquery-ui.js&#8221; type=”text/javascript” language=”javascript”></script>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js”></script&gt;
<script src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js”></script&gt;

 <script type=”text/javascript” src=”http://maps.googleapis.com/maps/api/js?sensor=false”></script&gt;

    <script type=”text/javascript”>
    var markers = [
    <asp:Repeater ID="rptMarkers" runat="server">
    <ItemTemplate>
             {
"ID": '<%# Eval("ID") %>',
                "title": '<%# Eval("Name") %>',
                "lat": '<%# Eval("lat") %>',
                "lng": '<%# Eval("lng") %>',
                "description": '<%# Eval("Description") %>'
            }
    </ItemTemplate>
    <SeparatorTemplate>
        ,
    </SeparatorTemplate>
    </asp:Repeater>
    ];
    </script>
   
<script type=”text/javascript” language=”javascript”>
var map = null;
window.onload = function () {
//alert(markers.length);
for (i = 0; i < markers.length; i++) {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var data = markers[i];

//var map = new google.maps.Map(document.getElementById(“dvMap” + (i + 1)), mapOptions);
var map = new google.maps.Map(document.getElementById(“dvMap” + data.ID), mapOptions);
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, “click”, function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}

function initializeMap() {
//alert(markers.length);
for (i = 0; i < markers.length; i++) {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var data = markers[i];

//var map = new google.maps.Map(document.getElementById(“dvMap” + (i + 1)), mapOptions);
var map = new google.maps.Map(document.getElementById(“dvMap” + data.ID), mapOptions);
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, “click”, function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}

$(function () {
for (i = 1; i < 6; i++) {
//var id = “#repAccordian1_ctl0″ + i + “_accordionChild1″;
var id = “#WebUserControl11_repAccordian1_ctl0″ + i + “_accordionChild1″;
//alert(id);
// $(id).accordion({active:true,
// heightStyle: “content”,
// collapsible: true,
// navigation: true

// });

$(id).accordion();

$(id).bind(‘accordionchange’, function (event, ui) {
//// if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {
//alert(“hahshds”);
initializeMap();
//}
});
}

});

$(document).ready(function () {

for (i = 0; i < 6; i++) {
//var id = “#repAccordian1_ctl0″ + i + “_accordionChild1″;
var id = “#WebUserControl11_repAccordian1_ctl0″ + i + “_accordionChild1″;
//alert(id);
// $(id).accordion({active:true,
// heightStyle: “content”,
// collapsible: true,
// navigation: true

// });

$(id).accordion();
$(id).bind(‘accordionchange’, function (event, ui) {
//// if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {
//alert(“hahshds”);
initializeMap();
//}
});
}
});
$(function () {

// $(“#accordion1″).accordion({ active: true,
// heightStyle: “content”,
// collapsible: true,
// navigation: true
// });

$(“#accordion1″).accordion();
$(“#accordion1″).bind(‘accordionchange’, function (event, ui) {
//if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {

initializeMap();
//}
});
});

$(document).ready(function () {
// $(“#accordion1″).accordion({active:true,
// heightStyle: “content”,
// collapsible: true,
// navigation: true

// });
$(“#accordion1″).accordion();
$(“#accordion1″).bind(‘accordionchange’, function (event, ui) {
// if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {

initializeMap();
//}
});
});
</script>

<div id=”accordion1″ style=”width: 900px;”>
<asp:Repeater runat=”server” ID=”repAccordian1″
onitemdatabound=”repAccordian1_ItemDataBound”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><asp:Label ID=”lblName” runat=”server” Text=’<%# Eval(“Name”) %>’></asp:Label></h3>
<%– <asp:Label ID=”lblID” runat=”server” Text=’<%#Eval(“ID”) %>’></asp:Label>–%>
<div id=”accordionChild1″ runat=”server” style=”width: 800px;”>
<asp:Repeater runat=”server” ID=”repAccordian” onitemdatabound=”repAccordian_ItemDataBound”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><%# Eval(“Name”) %></h3>
<%–<asp:Panel ID=”pnlTitle” runat=”server”></asp:Panel>–%>
<div>
<asp:UpdatePanel ID=”UpdatePanel22″ runat=”server”>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=”btnShowLabel” />
<asp:AsyncPostBackTrigger ControlID=”btnClear” />
</Triggers>
<ContentTemplate>
<asp:Panel ID=”pnl” runat=”server” Visible=’<%# ServerSideMethod(Convert.ToInt32(Eval(“ID”))) %> ‘>
<table border=”1″>
<tr>
<td>

<asp:Label ID=”lblName” Text=’<%#Eval(“ID”) %>’ runat=”server”></asp:Label>
<asp:Label ID=”lbllat” Text=’<%#Eval(“lat”) %>’ runat=”server”></asp:Label>
<asp:Label ID=”lbllng” Text=’<%#Eval(“lng”) %>’ runat=”server”></asp:Label>
</td>
<td>
FirstName:<asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
LastName:<asp:TextBox ID=”txtLName” runat=”server”></asp:TextBox>
</td>
<tr>
<td>
</td>
<td>
Email:<asp:TextBox ID=”txtEmail” runat=”server”></asp:TextBox>
</td>
<tr>
<td>
<asp:Button ID=”btnShowLabel” runat=”server” Text=”Submit” />
</td>
<td>
<asp:Button ID=”btnClear” runat=”server” Text=”Clear” />
</td>
</tr>
<tr>
<td>
<asp:Label ID=”lbShowing” runat=”server” />
</td>
</tr>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<table border=”1″>
<tr>
<td>
<b>Description</b>
</td>
<td>
<%#Eval(“Description”) %>
</td>
<td rowspan=”3″ colspan=”2″>
<b>Google Map</b>
<asp:UpdatePanel ID=”UpdatePanel1111″ runat=”server”>
<Triggers>
<asp:PostBackTrigger ControlID=”rptMaps” />

</Triggers>
<ContentTemplate>
<asp:Repeater ID=”rptMaps” runat=”server”>
        <ItemTemplate>
            <div id=’dvMap<%#Eval(“ID”) %>’ style=”width: 400px; height: 300px”>
            </div>
        </ItemTemplate>
        <SeparatorTemplate>
            <hr />
        </SeparatorTemplate>
    </asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel ID=”pnlDiv” runat=”server”>dvMap<%#Eval(“ID”) %>
 

</asp:Panel> <%–<div id=”Gmap” style=”height:300px;width:400px;border:1px;border-color:Red;border-style:solid;”></div>–%>
</td>
</tr>
<tr>
<td>
<b>Email</b>
</td>
<td>
<%#Eval(“Email”) %>
</td>
</tr>
<tr>

<td>
<b>Phone</b>
</td>
<td>
<%#Eval(“Phone”) %>
</td>

</tr>

</table>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
———————————————————–
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebApplicationRepeater
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

createAccordianUsingRepeater();

 

}
foreach (RepeaterItem ritem in repAccordian1.Items)
{
Repeater repAccordianChild = (Repeater)ritem.FindControl(“repAccordian”);
foreach (RepeaterItem ritem1 in repAccordianChild.Items)
{
Button btn = ritem1.FindControl(“btnShowLabel”) as Button;
btn.Click += new EventHandler(btn_Click);
Button btn1 = ritem1.FindControl(“btnClear”) as Button;
btn1.Click += new EventHandler(btn1_Click);
}
}

rptMarkers.DataSource = createDataTableGMAP(“MARKER”);
rptMarkers.DataBind();

}

 

void btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;
Label lb = (Label)ritem.FindControl(“lbShowing”);
TextBox txt = (TextBox)ritem.FindControl(“txtName”);
//getDATA(txt.Text);

((Label)ritem.FindControl(“lbShowing”)).Text = txt.Text;
((TextBox)ritem.FindControl(“txtName”)).Text = “”;

}
void btn1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;

((TextBox)ritem.FindControl(“txtName”)).Text = “”;

((TextBox)ritem.FindControl(“txtEmail”)).Text = “”;
((TextBox)ritem.FindControl(“txtLName”)).Text = “”;
((TextBox)ritem.FindControl(“txtName”)).Focus();
((Label)ritem.FindControl(“lbShowing”)).Text = “”;
}

public bool ServerSideMethod(int n)
{
if (Convert.ToInt32(n) % 2 == 0)
return true;
else
return false;
}
public string GETDIVID(string n)
{
return “#accordion” + n;
}

public DataTable createDataTableGMAP(string id)
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “lat”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “lng”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

if (id == “MARKER”)
{

dt.Rows.Add(new object[] { “110″, “Max 1 HYD”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 HYD”, “17.419640″, “78.483887″ });

 

dt.Rows.Add(new object[] { “120″, “Max 1111″, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″, “17.694596″, “83.283539″ });

dt.Rows.Add(new object[] { “130″, “Albert 2 CHE”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 Chennai “, “13.034864″, “80.256805″ });

dt.Rows.Add(new object[] { “140″, “Destin 3 BLR”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 BANGLRE “, “12.970636″, “77.587128″ });

dt.Rows.Add(new object[] { “150″, “Jessie 4 CBE”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 CBE “, “10.993301″, “76.938934″ });

dt.Rows.Add(new object[] { “160″, “Joe 5 OOTY”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 OOTY”, “11.408217″, “76.702728″ });

}
else
{
if (id == “110″)
dt.Rows.Add(new object[] { “110″, “Max 1 HYD”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 HYD”, “17.419640″, “78.483887″ });

if (id == “120″)
dt.Rows.Add(new object[] { “120″, “Max 1111″, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″, “17.694596″, “83.283539″ });
if (id == “130″)
dt.Rows.Add(new object[] { “130″, “Albert 2 CHE”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 Chennai “, “13.034864″, “80.256805″ });
if (id == “140″)
dt.Rows.Add(new object[] { “140″, “Destin 3 BLR”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 BANGLRE “, “12.970636″, “77.587128″ });
if (id == “150″)
dt.Rows.Add(new object[] { “150″, “Jessie 4 CBE”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 CBE “, “10.993301″, “76.938934″ });
if (id == “160″)
dt.Rows.Add(new object[] { “160″, “Joe 5 OOTY”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 OOTY”, “11.408217″, “76.702728″ });

}
return dt;

}

//using System.Data;
public DataTable createDataTable(string id)
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “lat”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “lng”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

if (id == “Max”)
{
dt.Rows.Add(new object[] { “110″, “Max 1 HYD”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 HYD”, “17.419640″, “78.483887″ });
dt.Rows.Add(new object[] { “120″, “Max 1111″, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″, “17.694596″, “83.283539″ });
}
if (id == “Albert”)
dt.Rows.Add(new object[] { “130″, “Albert 2 CHE”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 Chennai “, “13.034864″, “80.256805″ });
if (id == “Destin”)
dt.Rows.Add(new object[] { “140″, “Destin 3 BLR”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 BANGLRE “, “12.970636″, “77.587128″ });
if (id == “Jessie”)
dt.Rows.Add(new object[] { “150″, “Jessie 4 CBE”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 CBE “, “10.993301″, “76.938934″ });
if (id == “Joe”)
dt.Rows.Add(new object[] { “160″, “Joe 5 OOTY”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 OOTY”, “11.408217″, “76.702728″ });

return dt;

}

public void createAccordianUsingRepeater()
{
repAccordian1.DataSource = createDataTable1();
repAccordian1.DataBind();
}

public DataTable createDataTable1()
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);

dt.Columns.Add(dc);

dt.Rows.Add(new object[] { “1″, “Max”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″ });
dt.Rows.Add(new object[] { “2″, “Albert”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″ });
dt.Rows.Add(new object[] { “3″, “Destin”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″ });
dt.Rows.Add(new object[] { “4″, “Jessie”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″ });
dt.Rows.Add(new object[] { “5″, “Joe”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789″ });

return dt;

}

protected void repAccordian1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater repAccordianChild = (Repeater)item.FindControl(“repAccordian”);
Label lbl = (Label)item.FindControl(“lblName”);
string id = lbl.Text + item.ItemIndex.ToString();

//DataRowView drv = (DataRowView)item.DataItem;
repAccordianChild.DataSource = createDataTable(lbl.Text);
repAccordianChild.DataBind();

 

//System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), “Script”, “alert(‘” + id + “‘);”, true);
}
}

protected void repAccordian_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{

Control pnlTitle = item.FindControl(“pnlTitle”);

Control repAccordianChild1 = item.FindControl(“pnlDiv”);
Label lbl = (Label)item.FindControl(“lblName”);
Label lbllat = (Label)item.FindControl(“lbllat”);
Label lbllng = (Label)item.FindControl(“lbllng”);

DataTable dt = new DataTable();
dt = createDataTableGMAP(lbl.Text);

rptMarkers.DataSource = dt;
rptMarkers.DataBind();

Repeater rptMaps = (Repeater)item.FindControl(“rptMaps”);

rptMaps.DataSource = dt;
rptMaps.DataBind();

 

// string id = lbl.Text;// item.ItemIndex.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();//lbl.Text +
//string divid = “<div style=’ border:1px;border-color:Red;border-style:solid;width:500px; height:300px;’ id=’” + id.Replace(” “,””) + “‘>” + id.Replace(” “,””) + “</div>”;
//LiteralControl ltc = new LiteralControl(divid);
//string dividTitle = “<h3>” + lbl.Text + “</h3>”;
//LiteralControl ltcTitle = new LiteralControl(dividTitle);

//pnlTitle.Controls.Add(ltcTitle);

//repAccordianChild1.Controls.Add(ltc);

// System.Web.UI.ScriptManager.RegisterClientScriptBlock(repAccordianChild1, this.GetType(), “Script”, “ShowMap(” + id.Replace(” “, “”) + “,” + lbllat.Text.Replace(” “, “”) + “,” + lbllng.Text.Replace(” “, “”) + “);”, true);
}
}
}
}
——————————-

test

<%@ Assembly Name=”$SharePoint.Project.AssemblyFullName$” %>
<%@ Assembly Name=”Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=14.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”asp” Namespace=”System.Web.UI” Assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35″ %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Control Language=”C#” AutoEventWireup=”true” CodeBehind=”VisualWebPart1UserControl.ascx.cs”
Inherits=”VisualWebPartProjectContactUs.VisualWebPart1.VisualWebPart1UserControl” %>
<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css”&gt;
<script src=”http://code.jquery.com/jquery-1.9.1.js&#8221; type=”text/javascript” language=”javascript”></script>
<script src=”http://code.jquery.com/ui/1.10.4/jquery-ui.js&#8221; type=”text/javascript” language=”javascript”></script>
<link rel=”stylesheet” href=”http://jqueryui.com/resources/demos/style.css&#8221; />

 

<script type=”text/javascript” language=”javascript”>
$(function () {
for (i = 1; i < 6; i++) {
//var id = “#repAccordian1_ctl0″ + i + “_accordionChild1″;
var id = “#ctl00_ctl23_g_9ce9db84_b6e9_4849_b350_bdae4d70b845_ctl00_repAccordian1_ctl0″ + i + “_accordionChild1″;
//alert(id);
$(id).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true
});
}

});

$(document).ready(function () {

for (i = 0; i < 6; i++) {
//var id = “#repAccordian1_ctl0″ + i + “_accordionChild1″;
var id = “#ctl00_ctl23_g_9ce9db84_b6e9_4849_b350_bdae4d70b845_ctl00_repAccordian1_ctl0″ + i + “_accordionChild1″;
//alert(id);
//alert(id);
$(id).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true

});
}
});
$(function () {

$(“#accordion1″).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true
});
});

$(document).ready(function () {
$(“#accordion1″).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true

});
});
</script>

<div id=”accordion1″ style=”width: 800px;”>
<asp:Repeater runat=”server” ID=”repAccordian1″
onitemdatabound=”repAccordian1_ItemDataBound”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><asp:Label ID=”lblName” runat=”server” Text=’<%# Eval(“Name”) %>’></asp:Label></h3>
<%– <asp:Label ID=”lblID” runat=”server” Text=’<%#Eval(“ID”) %>’></asp:Label>–%>
<div id=”accordionChild1″ runat=”server” style=”width: 500px;”>
<asp:Repeater runat=”server” ID=”repAccordian”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><%#Eval(“Name”) %></h3>
<div>
<asp:UpdatePanel ID=”UpdatePanel22″ runat=”server”>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=”btnShowLabel” />
<asp:AsyncPostBackTrigger ControlID=”btnClear” />
</Triggers>
<ContentTemplate>
<asp:Panel ID=”pnl” runat=”server” Visible=’<%# ServerSideMethod(Convert.ToInt32(Eval(“ID”))) %> ‘>
<table border=”1″>
<tr>
<td>
<%#Eval(“ID”) %>
</td>
<td>
FirstName:<asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
LastName:<asp:TextBox ID=”txtLName” runat=”server”></asp:TextBox>
</td>
<tr>
<td>
</td>
<td>
Email:<asp:TextBox ID=”txtEmail” runat=”server”></asp:TextBox>
</td>
<tr>
<td>
<asp:Button ID=”btnShowLabel” runat=”server” Text=”Submit” />
</td>
<td>
<asp:Button ID=”btnClear” runat=”server” Text=”Clear” />
</td>
</tr>
<tr>
<td>
<asp:Label ID=”lbShowing” runat=”server” />
</td>
</tr>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<table>
<tr>
<td>
<b>Description</b>
</td>
<td>
<%#Eval(“Description”) %>
</td>
</tr>
<tr>
<td>
<b>Email</b>
</td>
<td>
<%#Eval(“Email”) %>
</td>
</tr>
<tr>
<td>
<b>Phone</b>
</td>
<td>
<%#Eval(“Phone”) %>
</td>
</tr>
</table>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
——————————————————————-
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;

namespace VisualWebPartProjectContactUs.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

createAccordianUsingRepeater();

}
foreach (RepeaterItem ritem in repAccordian1.Items)
{
Repeater repAccordianChild = (Repeater)ritem.FindControl(“repAccordian”);
foreach (RepeaterItem ritem1 in repAccordianChild.Items)
{
Button btn = ritem1.FindControl(“btnShowLabel”) as Button;
btn.Click += new EventHandler(btn_Click);
Button btn1 = ritem1.FindControl(“btnClear”) as Button;
btn1.Click += new EventHandler(btn1_Click);
}
}
}

 

void btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;
Label lb = (Label)ritem.FindControl(“lbShowing”);
TextBox txt = (TextBox)ritem.FindControl(“txtName”);
//getDATA(txt.Text);

((Label)ritem.FindControl(“lbShowing”)).Text = txt.Text;
((TextBox)ritem.FindControl(“txtName”)).Text = “”;

}
void btn1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;

((TextBox)ritem.FindControl(“txtName”)).Text = “”;

((TextBox)ritem.FindControl(“txtEmail”)).Text = “”;
((TextBox)ritem.FindControl(“txtLName”)).Text = “”;
((TextBox)ritem.FindControl(“txtName”)).Focus();
((Label)ritem.FindControl(“lbShowing”)).Text = “”;
}

public bool ServerSideMethod(int n)
{
if (Convert.ToInt32(n) % 2 == 0)
return true;
else
return false;
}
public string GETDIVID(string n)
{
return “#accordion” + n;
}

//using System.Data;
public DataTable createDataTable(string id)
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);

dt.Columns.Add(dc);

if (id == “Max”)
{
dt.Rows.Add(new object[] { “1″, “Max 1″, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789″ });
dt.Rows.Add(new object[] { “1″, “Max 1111″, “Hello my name is Max and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789″ });
}
if (id == “Albert”)
dt.Rows.Add(new object[] { “2″, “Albert 2″, “Hello my name is Albert and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789″ });
if (id == “Destin”)
dt.Rows.Add(new object[] { “3″, “Destin 3″, “Hello my name is Destin and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789″ });
if (id == “Jessie”)
dt.Rows.Add(new object[] { “4″, “Jessie 4″, “Hello my name is Jessie and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789″ });
if (id == “Joe”)
dt.Rows.Add(new object[] { “5″, “Joe 5″, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789″ });

return dt;

}

public void createAccordianUsingRepeater()
{
repAccordian1.DataSource = createDataTable1();
repAccordian1.DataBind();
}

public DataTable createDataTable1()
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);

dt.Columns.Add(dc);

dt.Rows.Add(new object[] { “1″, “Max”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My
Phone is 123456789″ });
dt.Rows.Add(new object[] { “2″, “Albert”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789″ });
dt.Rows.Add(new object[] { “3″, “Destin”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789″ });
dt.Rows.Add(new object[] { “4″, “Jessie”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789″ });
dt.Rows.Add(new object[] { “5″, “Joe”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My
Phone is 123456789″ });

return dt;

}

protected void repAccordian1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater repAccordianChild = (Repeater)item.FindControl(“repAccordian”);
Label lbl = (Label)item.FindControl(“lblName”);

//DataRowView drv = (DataRowView)item.DataItem;
repAccordianChild.DataSource = createDataTable(lbl.Text);
repAccordianChild.DataBind();
}
}
}
}

#Add-PSSnapin Microsoft.SharePoint.PowerShell

function Get-AllCQWPFromPage($WebAppName)
{
  $webapp = Get-SPWebApplication $WebAppName
  foreach ($site in $webapp.Sites)
  {
  foreach ($web in $site.AllWebs)        
  {
   #$web.URL
   if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))
    { 
     $pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
     $pages = $pubWeb.PagesList
     $pubPages = $pubWeb.GetPublishingPages()                    
    foreach ($item in $pages.Items)
    {
      $fileUrl=$Web.Url+”/Pages/”+$item.File.Name
                 $pubPage = $pubPages.get_Item($Web.Url+”/Pages/”+$item.File.Name)
     
                     $spFile = $web.GetFile($fileUrl)
     if($spFile.Exists)
     {
      $wpmanager = $spFile.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
      $wpcolleactions = $wpmanager.webparts
      foreach ($wp in $wpcolleactions)
      {                            
       $type = $wp.GetType()                           
        if ($type.FullName  -eq “Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart”)
       {                           
        Write-Host “Webpart Name : ” $wp.Title              
       }
      }
     }                 
            $web.Update()        
                                                  }      
   }
      elseif ($web.WebTemplate -eq “STS”) #TEAM Site
   {
    $pages = $web.Lists["Site Pages"]             
     if ($pages)
    {               
     foreach ($item in $pages.Items)
     {                   
      $fileUrl = $pWeb.Url + $webUrl + “/” + $item.File.Url                                         
           $spFile = $web.GetFile($fileUrl)                    
           if($spFile.Exists)
       {
       $manager = $spFile.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
       $wpcolleactions = $manager.webparts
       foreach ($wp in $wpcolleactions)
       {                                                  
        $type = $wp.GetType()                          
        if ($type.FullName  -eq “Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart”) #-and ($wpcolleactions.Count -gt 0))
        {                           
         Write-Host “Webpart Name : ” $wp.Title
        }
       }
      }
     }
    }
       }    
  } 
   }
}

Get-AllCQWPFromPage “http://ServerName:999

Just follow 5 steps given in the below url, to setting up SharePoint 2010 Installation & Development enviroment.

http://msdn.microsoft.com/en-us/library/ee554869.aspx

 

A user can be play one of the following roles in SharePoint

1.Reader – Has read-only access to the Web site.
2.Contributor – Can add content to existing document libraries and lists.
3.Web Designer – Can create lists and document libraries and customize pages in the Web site.
4.Administrator – Has full control of the Web site.

User Control:

  • User Controls (.ascx) derived from System.Web.UI.UserControl
  • Designed for single-application
  • Deployed as .ASCX and source code of the application
  • If the same control needs to be used in more than one application, it introduces redundancy and maintenance problems
  • We have to use within the application and it rests in the application directory.

Eg:A much better choice when you need static content within a fixed layout, for example, when you make headers and footers

Custom Control:

  • Custom controls derived from System.Web.UI.WebControls.WebControl or System.Web.UI.Controls
  • Designed so that it can be used by more than one application
  • Deployed either in the application’s Bin directory or in the global assembly cache
  • Distributed easily and without problems associated with redundancy and maintenance
  • we can keep it in the Toolbox and use it whenever we want

 More suited for when an application requires dynamic content to be displayed; can be reused across an application, for example, for a data bound table control with dynamic rows

Tag Cloud

Follow

Get every new post delivered to your Inbox.