Well i'm working an application which use a connection with SharePoint to load the list items.
I'm also using a dynamic table so new rows can be added by the user.
It takes more than 7 seconds before my page is asp.net page. I checked this with firebug.
Below is the code of my page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
namespace AdminCareWeb
{
public partial class DocumentToevoegen : System.Web.UI.Page
{
#region globalevars
SharePointContextToken contextToken;
string accessToken;
Uri sharepointUrl;
string contextTokenString;
string logoHoofding;
int initNumRows = 15;
public string jsSharePointURL;
//Instanties aanmaken van de klasses
static List<TableRow> TableRows = new List<TableRow>();
static Dictionary<int, Artikels> dicArtikels = new Dictionary<int, Artikels>();
Document huidigDocument = new Document();
Klanten huidigeKlant = new Klanten();
#endregion
#region properties
private int numOfRows
{
get
{
if (ViewState["RowsCount"] == null)
{
return 0;
}
else
{
return (int)ViewState["RowsCount"];
}
}
set
{
ViewState["RowsCount"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
try
{
string vorigePagina = Request.UrlReferrer.ToString();
//Controleer of de pagina gerefreshd werd of voor het eerst geladen wordt.
if (!vorigePagina.Contains("DocumentToevoegen.aspx"))
{
TableRows.Clear();
//Als de pagina voor de eerste keer geladen wordt moet de tabel leeggemaakt worden.
dicArtikels.Clear();
}
//Generate the Rows on Initial Load
if (!Page.IsPostBack && dicArtikels.Count == 0)
{
numOfRows = initNumRows;
Artikels artikel = new Artikels();
for (int i = 0; i < numOfRows; i++)
{
dicArtikels.Add(i, artikel);
}
}
GenerateTable(0, numOfRows);
//Controleer of security tokens al aanwezig zijn. Indien deze niet aanwezig zijn maak ze globaal aan.
if (PassThrough.contextTokenString != null)
{
ClientContext clientContext = ContextTokensOphalen();
jsSharePointURL = PassThrough.sharepointUrl.ToString();
}
else if (!IsPostBack)
{
Response.Write("Could not find a context token.");
return;
}
}
catch (Exception ex)
{
huidigDocument.log("DocumentToevoegen.aspx", "Page_Load", ex.Message.ToString());
}
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
ClientContext clientContext = ContextTokensOphalen();
try
{
bool foutief = false; ;
string adresgegevens = "";
#region parameters ophalen
Parameters ledig = new Parameters();
ledig.ledigParameters();
huidigDocument.ParametersLookup(clientContext);
huidigDocument.Parameters1Tekstregel(clientContext);
huidigDocument.ParametersMeerdereTekstregels(clientContext);
huidigDocument.ParametersJaNeen(clientContext);
//Controleer of de bankgegevens ingevuld werden.
if (Parameters.Bankgegevens != null && !string.IsNullOrEmpty(Parameters.Bankgegevens))
{
foutief = false;
lblBankgegevens.Text = Parameters.Bankgegevens.Replace("\r\n", "<br />");
}
if (Parameters.Naam != null && !string.IsNullOrEmpty(Parameters.Naam))
{
foutief = false;
adresgegevens += Parameters.Naam + "<br>";
}
if (Parameters.Adres != null && !string.IsNullOrEmpty(Parameters.Adres))
{
foutief = false;
adresgegevens += Parameters.Adres + "<br>";
}
if (Parameters.Adres2 != null && !string.IsNullOrEmpty(Parameters.Adres2))
{
foutief = false;
adresgegevens += Parameters.Adres2 + "<br>";
}
if (Parameters.Postcode != null && !string.IsNullOrEmpty(Parameters.Postcode))
{
foutief = false;
adresgegevens += Parameters.Postcode;
}
if (Parameters.Plaats != null && !string.IsNullOrEmpty(Parameters.Plaats))
{
foutief = false;
adresgegevens += " " + Parameters.Plaats + "<br>";
}
if (Parameters.Telefoon != null && Parameters.Telefoon.Length > 3)
{
foutief = false;
adresgegevens += "Tel: " + Parameters.Telefoon + "<br>";
}
if (Parameters.GSM != null && Parameters.GSM.Length > 3)
{
foutief = false;
adresgegevens += "GSM: " + Parameters.GSM + "<br>";
}
if (Parameters.Fax != null && Parameters.Fax.Length > 3)
{
foutief = false;
adresgegevens += "Fax: " + Parameters.Fax + "<br>";
}
if (Parameters.Ondernemingsnummer != null && Parameters.Ondernemingsnummer.Length > 3)
{
foutief = false;
adresgegevens += "BTW " + Parameters.Ondernemingsnummer + "<br>";
}
if (Parameters.RPR != null && !string.IsNullOrEmpty(Parameters.RPR))
{
foutief = false;
adresgegevens += "RPR " + Parameters.RPR + "<br>";
}
if (Parameters.Website != null && !string.IsNullOrEmpty(Parameters.Website))
{
foutief = false;
adresgegevens += Parameters.Website + "<br>";
}
if (Parameters.Email != null && !string.IsNullOrEmpty(Parameters.Email))
{
foutief = false;
adresgegevens += Parameters.Email + "<br>";
}
if (Parameters.Logo != null && Parameters.LogoHoofding.ToString() == "")
{
foutief = false;
imgLogo.ImageUrl = Parameters.Logo;
imgLogo.Visible = true;
}
if (Parameters.LogoHoofding.ToString() != "")
{
logoHoofd.Style.Add("BACKGROUND-IMAGE", "url(" + Parameters.LogoHoofding + ");width:794px;");
foutief = false;
logoHoofding = Parameters.LogoHoofding;
imgLogo.Visible = false;
}
if (Parameters.Logovoet != null)
{
foutief = false;
imgVoet.ImageUrl = Parameters.Logovoet;
imgVoet.Visible = true;
imgVoet.Height = 140;
imgVoet.Width = 794;
}
if (!foutief) { lblAdresgegevens.Text = adresgegevens; }
#endregion
}
catch (Exception ex)
{
huidigDocument.log("DocumentToevoegen.aspx", "Page_Load", ex.Message.ToString());
}
if (!Page.IsPostBack)
{
//Huidige datum ophalen volgens het Belgisch formaat.
//Datum wordt gebruikt om de Documentdatum in te stellen en de vervaldatum.
DateTime dt = DateTime.Now;
txtDocumentDatum.Text = dt.ToString("dd-MM-yyyy");
dt = dt.AddDays(30);
txtVervaldatum.Text = Parameters.Vervaldatum;
ddlLand.SelectedValue = "20";
lblIntraCom.Text = "";
try
{
#region klanten ophalen
//Klanten invullen met de opgehaalde waardes uit een Dictionary
foreach (KeyValuePair<string, string> klant in huidigeKlant.KlantenOphalen())
{
string naam = klant.Value;
ddlKlant.Items.Add(new System.Web.UI.WebControls.ListItem(naam, naam));
}
#endregion
#region dagboeken ophalen
//Dagboeken invullen met de opgehaalde waardes uit een Dictionary
foreach (KeyValuePair<string, string> dagboeken in huidigDocument.Dagboeken())
{
//ddlDagboek.Items.Clear();
string ID = dagboeken.Key;
string omschrijving = dagboeken.Value;
ddlDagboek.Items.Add(new System.Web.UI.WebControls.ListItem(omschrijving, ID));
}
#endregion
#region postcodes ophalen
//Postcodes invullen met de opgehaalde waardes uit een Dictionary
foreach (KeyValuePair<string, string> postcode in huidigeKlant.Postcodes())
{
string ID = postcode.Key;
string gemeente = postcode.Value;
ddlGemeente.Items.Add(new System.Web.UI.WebControls.ListItem(gemeente, ID));
}
huidigDocument.DocumentNummerOpvragen(int.Parse(ddlDagboek.SelectedValue));
txtDocNr.Text = huidigDocument.documentCode + " / " + huidigDocument.huidigDocumentNummer;
#endregion
#region landen ophalen
//Landen invullen met de opgehaalde waardes uit een Dictionary
foreach (KeyValuePair<string, string> land2 in huidigeKlant.Landen())
{
string ID = land2.Key;
string land = land2.Value;
ddlLand.Items.Add(new System.Web.UI.WebControls.ListItem(land, ID));
}
huidigDocument.DocumentTitelOpvragen(int.Parse(ddlDagboek.SelectedValue));
lblDocumentTitel.Text = huidigDocument.documentTitel;
#endregion
}
catch (Exception ex)
{
huidigDocument.log("DocumentToevoegen.aspx", "Page_Load", ex.Message.ToString());
}
}
}
private void GenerateTable(int existing, int rowsCount)
{
try
{
//Alle data halen uit de PassThrough class om opnieuw een connectie te maken met SharePoint
ClientContext clientContext = ContextTokensOphalen();
Table table = Page.Form.FindControl("tblArtikels") as Table;
if (table == null)
{
table = new Table();
table.ID = "tblArtikels";
Page.Form.Controls.Add(table);
}
else
{
if (existing == 0)
{
table.Controls.Clear();
}
}
//The number of Columns to be generated
const int colsCount = 6;//You can changed the value of 3 based on you requirements
// Now iterate through the table and add your controls
for (int i = existing; i < rowsCount; i++)
{
if (!dicArtikels.ContainsKey(i))
{
Artikels artikel = new Artikels();
dicArtikels.Add(i, artikel);
}
TableRow row = new TableRow();
for (int j = 0; j < colsCount; j++)
{
TableCell cell = new TableCell();
//means the first column of the Table
if (j == 0)
{
cell.Width = 40;
//Create the CheckBox
CheckBox cb = new CheckBox();
// Set a unique ID for each CheckBox
cb.ID = "CheckBoxRow_" + i + "Col_" + j;
// Add the control to the FIRST TableCell
cell.Controls.Add(cb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
//2de kolom
else if (j == 1)
{
cell.Width = 60;
//Create the TextBox
TextBox tb = new TextBox();
// Set a unique ID for each TextBox
tb.ID = "TextBoxRow_" + i + "Col_" + j;
tb.Width = 40;
tb.EnableViewState = true;
tb.EnableTheming = true;
// Add the control to the TableCell
cell.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
//Kolom 3
else if (j == 2)
{
cell.Width = 310;
cell.HorizontalAlign = HorizontalAlign.Right;
//Create the TextBox
TextBox tb = new TextBox();
// Set a unique ID for each TextBox
tb.ID = "TextBoxRow_" + i + "Col_" + j;
tb.Width = 290;
tb.EnableViewState = true;
tb.EnableTheming = true;
tb.TextMode = TextBoxMode.MultiLine;
// Add the control to the TableCell
cell.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
//Kolom 4
else if (j == 3)
{
cell.Width = 160;
cell.HorizontalAlign = HorizontalAlign.Right;
//Create the TextBox
TextBox tb = new TextBox();
// Set a unique ID for each TextBox
tb.ID = "TextBoxRow_" + i + "Col_" + j;
//tb.TextChanged += new EventHandler(txtArtikelPrijs_TextChanged);
tb.Width = 140;
tb.EnableViewState = true;
tb.EnableTheming = true;
// Add the control to the TableCell
cell.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
//Kolom 5
else if (j == 4)
{
cell.Width = 160;
cell.HorizontalAlign = HorizontalAlign.Right;
//Create the TextBox
TextBox tb = new TextBox();
// Set a unique ID for each TextBox
tb.ID = "TextBoxRow_" + i + "Col_" + j;
//tb.TextChanged += new EventHandler(txtArtikelPrijs_TextChanged);
tb.Width = 140;
tb.Enabled = false;
tb.BackColor = System.Drawing.ColorTranslator.FromHtml("#F2F2F2");
tb.TabIndex = -1;
tb.EnableViewState = true;
tb.EnableTheming = true;
// Add the control to the TableCell
cell.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
//Kolom 6
else if (j == 5)
{
cell.HorizontalAlign = HorizontalAlign.Right;
cell.Width = 64;
//Create the TextBox
DropDownList ddl = new DropDownList();
// Set a unique ID for each TextBox
ddl.ID = "DropDownRow_" + i + "Col_" + j;
ddl.Width = 50;
ddl.TabIndex = -1;
ddl.EnableViewState = true;
ddl.EnableTheming = true;
ddl.Items.Clear();
//Lijst met artikelen ophalen en dropdown opvullen
List oListBTW = clientContext.Web.Lists.GetByTitle("Lijst BTWcodes");
clientContext.ExecuteQuery();
CamlQuery cQBTW = new CamlQuery();
cQBTW.ViewXml = "<View>"
+ "<Query>"
+ "</Query>"
+ "</View>";
Microsoft.SharePoint.Client.ListItemCollection btwListItem = oListBTW.GetItems(cQBTW);
clientContext.Load(btwListItem);
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem btwItem in btwListItem)
{
string btwcode = btwItem["bcCode"].ToString();
string btwpercentage = btwItem["bcBTW"].ToString();
ddl.Items.Add(new System.Web.UI.WebControls.ListItem(btwpercentage, btwcode));
}
if (i >= initNumRows && ddlBTWregime.Items.Count > 0)
{
if (ddlBTWregime.SelectedItem.Value == "Medecontractant" || ddlBTWregime.SelectedItem.Value == "intracom goederen" || ddlBTWregime.SelectedItem.Value == "intracom diensten")
{
ddl.Enabled = false;
ddl.SelectedItem.Text = "0";
ddl.BackColor = System.Drawing.ColorTranslator.FromHtml("#F2F2F2");
}
else if (ddlBTWregime.SelectedItem.Value == "BTW 6%")
{
ddl.Enabled = false;
ddl.SelectedItem.Text = "6";
ddl.BackColor = System.Drawing.ColorTranslator.FromHtml("#F2F2F2");
}
else
{
ddl.Enabled = true;
ddl.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
}
}
// Add the control to the TableCell
cell.Controls.Add(ddl);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
}
// And finally, add the TableRow to the Table
tblArtikels.Rows.Add(row);
}
//Sore the current Rows Count in ViewState
numOfRows = rowsCount;
}
catch (Exception ex)
{
huidigDocument.log("DocumentToevoegen.aspx", "Genereer tabel", ex.Message.ToString());
}
}
Below the .cs file i'm using to get the list items from SharePoint =>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
namespace AdminCareWeb
{
public class Klanten
{
SharePointContextToken contextToken;
string accessToken;
string currentUser;
Uri sharepointUrl;
string contextTokenString;
Document logging = new Document();
#region props
public string KlantID { get; set; }
public string KlantNaam { get; set; }
public string KlantAdres { get; set; }
public string KlantAdres2 { get; set; }
public string KlantPostcode { get; set; }
public string KlantPlaats { get; set; }
public string KlantLand { get; set; }
public string KlantOndernemingsnummerVoorloopcode { get; set; }
public string KlantOndernemingsnummer { get; set; }
#endregion
//Lijst maken van alle landen uit de SharePoint lijst landen.
public Dictionary<string, string> Landen()
{
Dictionary<string, string> landenLijst = new Dictionary<string, string>();
try
{
contextToken = PassThrough.contextToken;
sharepointUrl = PassThrough.sharepointUrl;
accessToken = PassThrough.accessToken;
ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
// Lijst met Landen ophalen en dropdown vullen
List oListLanden = clientContext.Web.Lists.GetByTitle("Lijst landen");
clientContext.ExecuteQuery();
CamlQuery cQLand = new CamlQuery();
cQLand.ViewXml = "<View><Query></Query></View>";
Microsoft.SharePoint.Client.ListItemCollection landListItem = oListLanden.GetItems(cQLand);
clientContext.Load(landListItem, items => items.Include(
item => item["ID"],
item => item["LDnaam"]));
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem landItem in landListItem)
{
string ID = landItem["ID"].ToString();
string landNaam = landItem["LDnaam"].ToString();
landenLijst.Add(ID, landNaam);
}
}
catch (Exception ex)
{
logging.log("Klanten.cs", "Landen ophalen", ex.Message.ToString());
}
return landenLijst;
}
//Lijst maken van alle postcodes uit de SharePoint lijst postcodes en gemeentes.
public Dictionary<string, string> Postcodes()
{
Dictionary<string, string> postcodesLijst = new Dictionary<string, string>();
try
{
contextToken = PassThrough.contextToken;
sharepointUrl = PassThrough.sharepointUrl;
accessToken = PassThrough.accessToken;
ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
//Lijst met postcodes ophalen en dropdown opvullen
List oListPostcodes = clientContext.Web.Lists.GetByTitle("Lijst postcodes");
clientContext.ExecuteQuery();
CamlQuery cQPostcodes = new CamlQuery();
cQPostcodes.ViewXml = "<View>"
+ "<Query>"
+ "<OrderBy><FieldRef Name='PCgemeente'/></OrderBy>"
+ "</Query>"
+ "</View>";
//Lijst aanmaken met het resultaat van de uitgevoerde query.
Microsoft.SharePoint.Client.ListItemCollection postcodeListItem = oListPostcodes.GetItems(cQPostcodes);
clientContext.Load(postcodeListItem, items => items.Include(
item => item["ID"],
item => item["PCgemeente"]));
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem postcodeItem in postcodeListItem)
{
string ID = postcodeItem["ID"].ToString();
string gemeente = postcodeItem["PCgemeente"].ToString();
postcodesLijst.Add(ID, gemeente);
}
}
catch (Exception ex)
{
logging.log("Klanten.cs", "Postcodes ophalen", ex.Message.ToString());
}
return postcodesLijst;
}
//Lijst maken van alle landen uit de SharePoint lijst landen.
public Dictionary<string, string> KlantenOphalen()
{
Dictionary<string, string> klantenLijst = new Dictionary<string, string>();
try
{
contextToken = PassThrough.contextToken;
sharepointUrl = PassThrough.sharepointUrl;
accessToken = PassThrough.accessToken;
ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
// Lijst met Landen ophalen en dropdown vullen
List oListKLanten = clientContext.Web.Lists.GetByTitle("Lijst Relaties");
clientContext.ExecuteQuery();
CamlQuery cQKlant = new CamlQuery();
cQKlant.ViewXml = "<View>"
+ "<Query>"
+ "<Where><Eq><FieldRef Name='RLtyperelatie' /><Value Type='Choice'>Klant</Value></Eq></Where>"
+ "<OrderBy><FieldRef Name='RLnaam'/></OrderBy>"
+ "</Query>"
+ "</View>";
Microsoft.SharePoint.Client.ListItemCollection klantListItem = oListKLanten.GetItems(cQKlant);
clientContext.Load(klantListItem, items => items.Include(
item => item["RLnaam"]));
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem klantItem in klantListItem)
{
string klantNaam = klantItem["RLnaam"].ToString();
klantenLijst.Add(klantNaam, klantNaam);
}
}
catch (Exception ex)
{
logging.log("Klanten.cs", "Klanten ophalen", ex.Message.ToString());
}
return klantenLijst;
}
}
}
Anyone have some suggestions to speed up. Well the problem is now it takes 7 -8 seconds before the page is showing up. Postbacks takes 3-5 seconds.
Related
I'm trying to add multi-selected items to list _AT.SOrderDetails = new List<SOrderDetail>(); but the list is overwritten by the last record selected. The list at right Datagrid only shows data of the last selected record of the left Datagrid instead of all records
foreach (int i in ((GridView)gridControl3.MainView).GetSelectedRows())
{
DataRowView oSOrder = (DataRowView)((GridView)gridControl3.MainView).GetRow(i);
int id = Convert.ToInt32(oSOrder.Row.ItemArray[0]);
if (oSOrder == null)
{
MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
int x = Convert.ToInt32(oSOrder["SOrderID"]);
_Order = db.SOrderTables.FirstOrDefault(o => o.QSOrdersID == x);
SOrderTable oOrder = null;
oOrder = _Order;
if (_Order != null)
{
_AT.SOrderDetails = new List<SOrderDetail>();
if (_Order.SOrderDetails != null)
{
foreach (SOrderDetail oPODItem in _Order.SOrderDetails.ToList())
{
_OrderDetail = new SOrderDetail();
Product oProduct = db.Products.FirstOrDefault(o => o.ProductID == oPODItem.ProductID);
_OrderDetail.ProductID = oPODItem.ProductID;
_OrderDetail.Description = oProduct.Description;
_OrderDetail.Quantity = oPODItem.Quantity;
_OrderDetail.Form = oPODItem.Form;
_OrderDetail.Price = oPODItem.Price;
_AT.SOrderDetails.Add(_OrderDetail);
}
}
}
}
The list at right Datagrid only shows data of the last selected record of the left datagrid
How do I add all values of the selected records, I need help I'm still new, thank you.
i created a new list _tapiwa.SOrderDetails = new List<SOrderDetail>(); So i was now saving information from list _Order.SOrderDetails.ToList(); to the new list i created.
`foreach (int i in ((GridView)gridControl3.MainView).GetSelectedRows())
{
DataRowView oSOrder = (DataRowView)((GridView)gridControl3.MainView).GetRow(i);
int id = Convert.ToInt32(oSOrder.Row.ItemArray[0]);
if (oSOrder == null)
{
MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
int x = Convert.ToInt32(oSOrder["SOrderID"]);
_Order = db.SOrderTables.FirstOrDefault(o => o.QSOrdersID == x);
label1.Text += (oSOrder.Row.ItemArray[0]).ToString()+" "+ (oSOrder.Row.ItemArray[1]).ToString()+" " + (oSOrder.Row.ItemArray[2]).ToString()+ "\n";
SOrderTable oOrder = null;
// db = new MedriveEntities();
oOrder = _Order;
if (_Order != null)
{
if (_tapiwa == null)
{
_tapiwa = new SOrderTable();
_tapiwa.SOrderDetails = new List<SOrderDetail>();
}
foreach (SOrderDetail oPODItem in oOrder.SOrderDetails.ToList())
{
_OrderDetail = new SOrderDetail();
// label2.Text += oPODItem.ProductID.ToString() + " " + oPODItem.Description.ToString() + " " + oPODItem.Quantity.ToString() + "\n";
Product oProduct = db.Products.FirstOrDefault(o => o.ProductID == oPODItem.ProductID);
_OrderDetail.ProductID = oPODItem.ProductID;
_OrderDetail.Description = oProduct.Description;
_OrderDetail.Quantity = oPODItem.Quantity;
_OrderDetail.Form = oPODItem.Form;
_OrderDetail.Price = oPODItem.Price;
_tapiwa.SOrderDetails.Add(_OrderDetail);
}
}
}
RefreshList1();`
I am developing the my asp.net project, I'm try to make ASP.net text box for Auto Generate code, but its not working correctly, sample Auto Generate code = ID1.
I'm try to use this part,
string txt = txtBatchNo.Text;
txtBatchNo.Text = "C" + Convert.ToInt32(txt.Substring(1, txt.Length - 1)) + 1;
Code:
protected void btnAdd_Click(object sender, EventArgs e)
{
int newId = 1;
if (selectGRNDetailId == -1)
{
{
try
{
if (dtFabricItem.Rows.Count > 0)
{
newId = Convert.ToInt32(dtFabricItem.Rows[dtFabricItem.Rows.Count - 1]["GRNDetailsID"].ToString()) + 1;
}
}
catch (Exception)
{
newId = 1;
}
}
}
else
{
newId = selectGRNDetailId;
}
if (dtFabricItem == null)
{
CreateFabricDetails();
dtFabricItem = dt;
}
else
{
CreateFabricDetails();
}
DataRow dr2 = null;
dr2 = dt.NewRow();
dr2["GRNDetailsID"] = newId;
dr2["GRNDetailID"] = selectGRNId;
dr2["BatchNO"] = txtBatchNo.Text;
dr2["ItemId"] = Convert.ToInt32(ddlYarnName.SelectedValue);
dr2["ItemName"] = ddlYarnName.SelectedItem.Text;
dr2["LotId"] = Convert.ToInt32(ddlLotNo.SelectedValue);
dr2["LotName"] = ddlLotNo.SelectedItem.Text;
dr2["FibetLot"] = txtFiberLot.Text;
dr2["ContainsNo"] = txtContainsNO.Text;
dr2["Shade"] = txtShade.Text;
dr2["Quantity"] = Convert.ToDecimal(txtQty.Text).ToString();
dr2["YarnPrice"] = Convert.ToDecimal(txtYarnPrice.Text).ToString();
dr2["Cornweight"] = Convert.ToDecimal(txtCornWeight.Text).ToString();
dr2["BoxWeight"] = Convert.ToDecimal(txtBoxWeight.Text).ToString();
dr2["NumberofCones"] = Convert.ToDecimal(txtNumberofcones.Text).ToString();
dr2["Numberofboxes"] = Convert.ToDecimal(txtNumberofboxes.Text).ToString();
dt.Rows.Add(dr2);
//txtNumberofcones.Text = (Convert.ToDecimal(txtBoxWeight.Text) / Convert.ToDecimal(txtCornWeight.Text)).ToString();
if (dtFabricItem == null || dtFabricItem.Rows.Count == 0)
{
dtFabricItem = dt;
dtFabricItem.PrimaryKey = new DataColumn[] { dtFabricItem.Columns["GRNDetailsID"] };
}
else
{
dtFabricItem.PrimaryKey = new DataColumn[] { dtFabricItem.Columns["GRNDetailsID"] };
dtFabricItem.Merge(dt);
}
//dtFabricItem.PrimaryKey = new DataColumn[] { dtFabricItem.Columns["GRNDetailsID"] };
dtFabricItem.AcceptChanges();
gvrItemDetails.DataSource = dtFabricItem;
gvrItemDetails.DataBind();
selectGRNDetailId = -1;
ClearDetails();
}
TextBox Id = `txtBatchNo`
I am trying to make paging item counter something like __ of _ items like 1-6 pf 21 item and 6-12 of 21. can someone show me how to do it ??
private void BindResourcesRepater()
{
string tag = Request.QueryString["tag"];
if (String.IsNullOrEmpty(tag))
{
//Guid userID = Guid.Parse(Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString());
DataSet ds = new DataSet();
int selectedTopicID = Convert.ToInt32(ddlTopics.SelectedValue);
int selectedSkillID = Convert.ToInt32(ddlSkills.SelectedValue);
int selectedTypeID = Convert.ToInt32(ddlTypes.SelectedValue);
string keyword = txtbKeyword.Text.Trim();
int sortBy = Convert.ToInt32(ddlSortBy.SelectedValue);
ds = Resource.Search_Resource(selectedTopicID, selectedSkillID, selectedTypeID, keyword, sortBy);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 6;
int curpage;
if (ViewState["Page"] != null)
{
curpage = Convert.ToInt32(ViewState["Page"]);
}
else
{
ViewState["Page"] = 1;
curpage = 1;
}
// Set the currentindex
objPds.CurrentPageIndex = curpage - 1;
// Display the current page
// lblCurrentPage.Text = "Page: " + (curpage).ToString() + " of " + objPds.PageCount.ToString();
rp_resList.DataSource = objPds;
rp_resList.DataBind();
if (rp_resList.Items.Count == 0)
{
lnkNext.Visible = false;
if (Convert.ToInt32(ViewState["Page"]) == 1)
{
lnkPrev.Visible = false;
}
else
{
lnkNext.Visible = false;
}
}
else
{
lnkNext.Visible = true;
if (rp_resList.Items.Count < objPds.PageSize)
{
lnkNext.Visible = false;
}
if (Convert.ToInt32(ViewState["Page"]) == 1)
{
lnkPrev.Visible = false;
}
else
{
lnkPrev.Visible = true;
}
}
}
else
{
DataSet ds = new DataSet();
int selectedTopicID = Convert.ToInt32(ddlTopics.SelectedValue);
int selectedSkillID = Convert.ToInt32(ddlSkills.SelectedValue);
int selectedTypeID = Convert.ToInt32(ddlTypes.SelectedValue);
txtbKeyword.Text = tag;
string keyword = tag.ToString();
int sortBy = Convert.ToInt32(ddlSortBy.SelectedValue);
ds = Resource.Search_Resource(selectedTopicID, selectedSkillID, selectedTypeID, tag, sortBy);
lbl_totalResult.Text = ds.Tables[0].Rows.Count.ToString() + " " + "Resources Found";
rp_resList.DataSource = ds.Tables[0];
rp_resList.DataBind();
}
}
Try this:
private void BindResourcesRepater()
{
// your existing code...
int numberOfItems = ds.Tables[0].Rows.Count;
lblCurrentVisibleItems.Text = GetCurrentVisibleItemsText(numberOfItems, objPds.PageSize, objPds.CurrentPageIndex);
}
private string GetCurrentVisibleItemsText(int numberOfItems, int pageSize, int currentPageIndex)
{
int startVisibleItems = currentPageIndex * pageSize + 1;
int endVisibleItems = Math.Min((currentPageIndex + 1) * pageSize, numberOfItems);
return string.Format("Displaying {0}-{1} of {2} items", startVisibleItems, endVisibleItems, numberOfItems);
}
I'm not sure what label you want to display this in, but in my example I've used one called lblCurrentVisibleItems. Replace this with whatever label you want to use.
I have created a composite control. There is no build error in it.
In the composite control i am using a Entity Framework Object
The problem is that in the design window i get the error message as shown in PIC:
There is no Error during build and composite control works well.
I just want to remove this error from Design Time window
EDIT:
Its like how i am adding the composite control:
<tr>
<td colspan="3">
<cc1:AdditionalColumnsCustomControl ID="AdditionalColumnsCustomControl1" runat="server"
MainCssClass="A" ControlMode="New" TableID="1" AreValidatorsStatic="true"
CustomControlWrapper="TableWrapper" ValidationGroup="vl" />
</td>
</tr>
In this case how i can i code to get rid of this Design surface error.
Composite COntrol SOurce COde:
public class AddRowCustomControl : CompositeControl
{
public void Clear()
{
Control c = (Control)FindControl(controlID);
if (c.GetType() == typeof(DropDownList))
{
DropDownList dl = c as DropDownList;
ListItem lsa = dl.SelectedItem;
lsa.Selected = false;
}
else if (c.GetType() == typeof(ListBox))
{
ListBox lb = c as ListBox;
foreach (ListItem ls in lb.Items)
{
if (ls.Selected)
{
ls.Selected = false;
}
}
}
else if (c.GetType() == typeof(RadioButtonList))
{
RadioButtonList rl = c as RadioButtonList;
foreach (ListItem ls in rl.Items)
{
if (ls.Selected)
{
ls.Selected = false;
}
}
}
else if (c.GetType() == typeof(CheckBoxList))
{
CheckBoxList cl = c as CheckBoxList;
foreach (ListItem ls in cl.Items)
{
if (ls.Selected)
{
ls.Selected = false;
}
}
}
else if (c.GetType() == typeof(CheckBox))
{
CheckBox chk = c as CheckBox;
chk.Checked = false;
}
else
{
TextBox tx = c as TextBox;
tx.Text = "";
}
}
public void Rebind()
{
Control c = (Control)FindControl(controlID);
fillControl(ref c , RowID , ColumnID);
}
public string SaveControlValuesInDB()
{
using (ExtEntities context = new ExtEntities())
{
if (RowID != null && ColumnID != null)
{
EntityData ed = context.EntityDatas.Where(p => p.ColID == ColumnID && p.RowID == RowID).FirstOrDefault();
if (ed == null)
{
ed = new EntityData();
ed.RowID = Convert.ToInt32(RowID);
ed.ColID = ColumnID;
ed.ColValue = ControlValue;
context.AddToEntityDatas(ed);
context.SaveChanges();
return "Successfully Added";
}
else
{
ed.ColValue = ControlValue;
context.SaveChanges();
return "Successfully Updated";
}
}
else
{
return "Exception Invalid Row ID";
}
}
}
public int? RowID
{
get;
set;
}
public enum Modes
{
New = 0,
Modify = 1,
ModifyInGrid = 2,
}
public Modes? ControlMode
{
get;
set;
}
public int ColumnID
{
get;
set;
}
public string ValidationGroup
{
get;
set;
}
/// <summary>
/// Specifes the Display mode of the Validators "Static or Dynamic"
/// </summary>
public bool? AreValidatorsStatic
{
get;
set;
}
/// <summary>
/// If true, the wrapper will be DIV's else Table
/// </summary>
public Wrapper CustomControlWrapper
{
get;
set;
}
public enum Wrapper
{
DivWrapper = 0,
TableWrapper = 1,
}
/// <summary>
/// Css Class Name for Custom Control
/// </summary>
public string MainCssClass
{
get;
set;
}
/// <summary>
/// Css Class Name for Custom Control Label
/// </summary>
public string LabelCssClass
{
get;
set;
}
/// <summary>
/// Css Class Name for Custom Control's Main Control
/// </summary>
public string ControlCssClass
{
get;
set;
}
/// <summary>
/// Css Class Name for Custom Control's Validators
/// </summary>
public string ValidatorCssClass
{
get;
set;
}
protected override void OnLoad(EventArgs e)
{
if (AreValidatorsStatic == null)
{
AreValidatorsStatic = false;
}
if (CustomControlWrapper == null)
{
CustomControlWrapper = Wrapper.DivWrapper;
}
if (string.IsNullOrEmpty(MainCssClass))
{
MainCssClass = "CustomControlMainClass";
}
if (string.IsNullOrEmpty(ControlCssClass))
{
ControlCssClass = "ControlCssClass";
}
if (string.IsNullOrEmpty(LabelCssClass))
{
LabelCssClass = "LabelCssClass";
}
if (string.IsNullOrEmpty(ValidatorCssClass))
{
ValidatorCssClass = "ValidatorCssClass";
}
if (ControlMode == null)
{
ControlMode = Modes.New;
}
base.OnLoad(e);
}
string controlID = "ControlID";
public string ControlValue
{
get
{
Control c = (Control)FindControl(controlID);
StringBuilder sb = new StringBuilder();
if (c.GetType() == typeof(DropDownList))
{
DropDownList dl = c as DropDownList;
sb.Append(dl.Text);
return sb.ToString();
}
else if (c.GetType() == typeof(ListBox))
{
ListBox lb = c as ListBox;
foreach (ListItem item in lb.Items)
{
if (item.Selected)
{
sb.Append(item.Text + "`");
}
}
return sb.ToString().TrimEnd('`');
}
else if (c.GetType() == typeof(RadioButtonList))
{
RadioButtonList rl = c as RadioButtonList;
sb.Append(rl.SelectedItem.Value);
return sb.ToString();
}
else if (c.GetType() == typeof(CheckBoxList))
{
CheckBoxList cl = c as CheckBoxList;
foreach (ListItem li in cl.Items)
{
if (li.Selected == true)
{
sb.Append(li.Text + "`");
}
}
return sb.ToString().TrimEnd('`');
}
else if (c.GetType() == typeof(CheckBox))
{
CheckBox chk = c as CheckBox;
return chk.Checked ? "TRUE" : "";
}
else
{
TextBox tx = c as TextBox;
return tx.Text;
}
}
}
private void AddOptions(string[] options, ref Control c)
{
if (c.GetType() == typeof(DropDownList))
{
DropDownList dl = c as DropDownList;
foreach (string item in options)
{
dl.Items.Add(item);
}
c = dl;
}
else if (c.GetType() == typeof(ListBox))
{
ListBox lb = c as ListBox;
foreach (string item in options)
{
lb.Items.Add(item);
}
c = lb;
}
else if (c.GetType() == typeof(RadioButtonList))
{
RadioButtonList rl = c as RadioButtonList;
foreach (string item in options)
{
rl.Items.Add(item);
}
c = rl;
}
else if (c.GetType() == typeof(CheckBoxList))
{
CheckBoxList cl = c as CheckBoxList;
foreach (string item in options)
{
cl.Items.Add(item);
}
c = cl;
}
}
protected override void CreateChildControls()
{
string ts = MainCssClass;
using (ExtEntities context = new ExtEntities())
{
EntityAttribute _Attribute = context.EntityAttributes.Where(p => p.ID == ColumnID).FirstOrDefault();
if (_Attribute != null)
{
Panel pnl = new Panel();
string[] _options = null;
if (_Attribute.ControlOptions != null)
{
_options = _Attribute.ControlOptions.Split('`');
}
Label lt = new Label();
lt.ID = "LabelID";
lt.Text = _Attribute.ColumnLabel;
Control c = null;
int? MaxLength = _Attribute.MaxLength;
bool Invalidate_Validator = false;
switch (_Attribute.AttributeTypeID)
{
case 1:
TextBox sl = new TextBox();
if (_Attribute.MaxLength != null)
sl.MaxLength = Convert.ToInt32(_Attribute.MaxLength);
c = sl;
break;
case 2:
TextBox ml = new TextBox();
ml.TextMode = TextBoxMode.MultiLine;
if (_Attribute.MaxLength != null)
ml.MaxLength = Convert.ToInt32(_Attribute.MaxLength);
c = ml;
break;
case 3:
DropDownList dl = new DropDownList();
c = dl;
break;
case 4:
ListBox lb = new ListBox();
lb.SelectionMode = ListSelectionMode.Multiple;
c = lb;
break;
case 5:
TextBox p = new TextBox();
p.TextMode = TextBoxMode.Password;
if (_Attribute.MaxLength != null)
p.MaxLength = Convert.ToInt32(_Attribute.MaxLength);
c = p;
break;
case 6:
CheckBox ck = new CheckBox();
Invalidate_Validator = true;
ck.Text = _options != null ? _options[0] : "N/A";
c = ck;
break;
//case 7:
// RadioButton rb = new RadioButton();
// rb.Text = _options != null ? _options[0] : "N/A";
// c = rb;
// break;
case 8:
RadioButtonList rb_list = new RadioButtonList();
c = rb_list;
break;
case 9:
CheckBoxList ck_list = new CheckBoxList();
Invalidate_Validator = true;
c = ck_list;
break;
default:
break;
}
RequiredFieldValidator req = null;
RegularExpressionValidator regx = null;
AddOptions(_options, ref c);
c.ID = controlID;
if (!Invalidate_Validator)
{
if (_Attribute.Mandatory)
{
req = new RequiredFieldValidator();
req.ControlToValidate = c.ID;
req.ErrorMessage = _Attribute.ValidationMessage;
req.Text = "*";
req.Display = AreValidatorsStatic == true ? ValidatorDisplay.Static : ValidatorDisplay.Dynamic;
req.ValidationGroup = ValidationGroup;
}
if (_Attribute.RegularExpressionValue != null)
{
regx = new RegularExpressionValidator();
regx.ControlToValidate = c.ID;
regx.ErrorMessage = _Attribute.ValidationMessage;
regx.Text = "*";
regx.ValidationGroup = ValidationGroup;
regx.ValidationExpression = _Attribute.RegularExpressionValue;
regx.Display = AreValidatorsStatic == true ? ValidatorDisplay.Static : ValidatorDisplay.Dynamic;
}
}
if (ControlMode == Modes.Modify)
{
fillControl(ref c, RowID, ColumnID);
}
if (CustomControlWrapper == Wrapper.DivWrapper)
{
pnl.Controls.Add(new LiteralControl(#"<div class=""" + MainCssClass + #"""><div class=""" + LabelCssClass + #""">"));
if (ControlMode != Modes.ModifyInGrid)
pnl.Controls.Add(lt);
pnl.Controls.Add(new LiteralControl(#"</div><div class=""" + ControlCssClass + #""">"));
pnl.Controls.Add(c);
pnl.Controls.Add(new LiteralControl(#"</div><div class=""" + ValidatorCssClass + #""">"));
if (req != null)
pnl.Controls.Add(req);
if (regx != null)
pnl.Controls.Add(regx);
pnl.Controls.Add(new LiteralControl(#"</div>"));
pnl.Controls.Add(new LiteralControl(#"</div>"));
}
else
{
pnl.Controls.Add(new LiteralControl(#"<table class=""" + MainCssClass + #"""><tr><td class=""" + LabelCssClass + #""">"));
if (ControlMode != Modes.ModifyInGrid)
pnl.Controls.Add(lt);
pnl.Controls.Add(new LiteralControl(#"</td><td class=""" + ControlCssClass + #""">"));
pnl.Controls.Add(c);
pnl.Controls.Add(new LiteralControl(#"</td><td class=""" + ValidatorCssClass + #""">"));
if (req != null)
pnl.Controls.Add(req);
if (regx != null)
pnl.Controls.Add(regx);
pnl.Controls.Add(new LiteralControl(#"</td></tr>"));
pnl.Controls.Add(new LiteralControl(#"</table>"));
}
Controls.Add(pnl);
}
}
}
private void fillControl(ref Control c, int? RowID, int ColumnID)
{
using (ExtEntities context = new ExtEntities())
{
EntityData obj = context.EntityDatas.Where(p => p.RowID == RowID && p.ColID == ColumnID).FirstOrDefault();
if (obj != null)
{
string[] values = obj.ColValue.Split('`');
string value = obj.ColValue;
if (c.GetType() == typeof(DropDownList))
{
DropDownList dl = c as DropDownList;
dl.Items.FindByText(value).Selected = true;
}
else if (c.GetType() == typeof(ListBox))
{
ListBox lb = c as ListBox;
foreach (var item in values)
{
lb.Items.FindByText(value).Selected = true;
}
}
else if (c.GetType() == typeof(RadioButtonList))
{
RadioButtonList rl = c as RadioButtonList;
foreach (var item in values)
{
rl.Items.FindByText(item).Selected = true;
}
}
else if (c.GetType() == typeof(CheckBoxList))
{
CheckBoxList cl = c as CheckBoxList;
foreach (var item in values)
{
cl.Items.FindByText(value).Selected = true;
}
}
else if (c.GetType() == typeof(CheckBox))
{
CheckBox chk = c as CheckBox;
chk.Checked = value == "TRUE" ? true : false;
}
else
{
TextBox tx = c as TextBox;
tx.Text = value;
}
}
}
}
Thanks
Any help is appreciated.
This is due to the fact that at design time the EF objects won't be available/instantiated. Can verify whether your control is currently be displayed on a design surface with the DesignMode property (MSDN doc):
if(this.DesignMode == false)
{
//do normal instantiations of objects etc.
}
else
{
//do work related to creating a design time view of your control
}
It sounds like you have a dependency that the designer is unable to resolve. You can use the DesignMode flag to help with this:
http://msdn.microsoft.com/en-us/library/system.componentmodel.component.designmode.aspx
After some minor difficulties with my basic test rating control not working because of the missing inline CSS stylesheet, I am trying to dynamically add a bunch of rating controls in a updatepanel when I click on a button in a different updatepanel. (These panels are both in a parent updatepanel, I have defined the triggers and set the updatemode to conditional). Anyways, when I click the button, he updates the updatepanel with the rating controls, but when I hover over them, he always displays 0 (the current rating), and does not change the rating control star image (filledStarRating). The code relevant to my problem (two methods):
protected void imbformulier_Click(Object sender, ImageClickEventArgs e)
{
imbFormulier.Visible = false;
imbGebruikers.Visible = false;
imbModellen.Visible = false;
pnlGegevens1.Visible = false;
pnlGegevens2.Visible = true;
pnlNavigatie.Visible = true;
pnlEval.Visible = true;
//kijken welk formulier moet ingevuld worden adhv de ddl's en dit meegeven aan de zelfgemaakte klasse
List<EvaluatieFormulier> mijnformulieren = (List<EvaluatieFormulier>)Session["mijnformulieren"];
IEnumerator<EvaluatieFormulier> enumerator = mijnformulieren.GetEnumerator();
EvaluatieFormulier meetegeven = new EvaluatieFormulier();
while (enumerator.MoveNext())
{
if (((enumerator.Current.GebruikergeevalueerdID == ddlGebruikers.SelectedValue) && (enumerator.Current.ModelID == Convert.ToInt32(ddlModellen.SelectedValue))))
{
meetegeven = enumerator.Current;
//Eventueel tekst veranderen als er al was gewerkt aan een bepaalde evaluatie
if (meetegeven.Tijdaangewerkt == 0)
{
lblInfo.Text = "Evaluatie gestart van " + ddlGebruikers.SelectedItem.Text;
lblDatum.Text = "Evaluatie begonnen op: "+ DateTime.Now.Date.ToString("d/M/yyyy") + "(Vandaag)" ;
//updaten in database
Session["aantalminutenaangewerkt"] = 0;
Session["aantalsecondenaangewerkt"] = 0;
timTijdAanGewerkt.Enabled = true;
lblTijd.Visible = true;
}
else
{
lblInfo.Text = "Evaluatie verdergezet van " + ddlGebruikers.SelectedItem.Text;
lblDatum.Text = "Evaluatie laatst gewijzigd : " + meetegeven.Tijdingevuld.ToString();
Session["aantalminutenaangewerkt"] = meetegeven.Tijdaangewerkt;
Session["aantalsecondenaangewerkt"] = 0;
timTijdAanGewerkt.Enabled = true;
lblTijd.Visible = true;
}
}
}
//Rating controls aanmaken voor elke criteria
List<AjaxControlToolkit.Rating> lijstratingcontrols = new List<AjaxControlToolkit.Rating>();
Model modelmetdomeinen = new Model() ;
IEnumerator<Model> modelenum = Database.laadModellenIn().GetEnumerator();
while (modelenum.MoveNext())
{
if (modelenum.Current.ModelID == meetegeven.ModelID)
modelmetdomeinen = modelenum.Current;
}
//foreach (Domein domein in modelmetdomeinen.Domeins)
//{
// foreach (Criterium criterium in domein.Criteriums)
// {
// AjaxControlToolkit.Rating ratingcontrol = new AjaxControlToolkit.Rating();
// ratingcontrol.ID = criterium.CriteriumNaam;
// ratingcontrol.StarCssClass = "ratingStar";
// ratingcontrol.EmptyStarCssClass = "emptyStarRating";
// ratingcontrol.WaitingStarCssClass = "emptyStarRating";
// ratingcontrol.FilledStarCssClass = "filledStarRating";
// ratingcontrol.Changed += new AjaxControlToolkit.RatingEventHandler(rating_Changed);
// ToolkitScriptManager1.RegisterAsyncPostBackControl(ratingcontrol);
// lijstratingcontrols.Add(ratingcontrol);
// }
//}
//Evaluatieform formulier = new Evaluatieform(meetegeven,lijstratingcontrols);
Table evaluatietabel = new Table();
int domeinteller =0;
foreach (Domein domein in modelmetdomeinen.Domeins)
{
domeinteller++;
if (domeinteller < 4)
{
TableRow domeinrij = new TableRow();
TableCell domeintitel = new TableCell();
domeintitel.Text = domeinteller + ". " + domein.DomeinNaam;
domeintitel.BorderStyle = BorderStyle.None;
domeinrij.Cells.Add(domeintitel);
evaluatietabel.Rows.Add(domeinrij);
foreach (Criterium criterium in domein.Criteriums)
{
int criteriumteller = 1;
TableRow criteriumrij = new TableRow();
TableCell criteriumtitel = new TableCell();
TableCell opvulcell = new TableCell();
TableCell ratingcell = new TableCell();
criteriumtitel.BorderStyle = BorderStyle.None;
opvulcell.BorderStyle = BorderStyle.None;
ratingcell.BorderStyle = BorderStyle.None;
criteriumtitel.Text = criteriumteller + ". " + criterium.CriteriumNaam;
AjaxControlToolkit.Rating ratingcontrol = new AjaxControlToolkit.Rating();
ratingcontrol.ID = criterium.CriteriumNaam;
ratingcontrol.StarCssClass = "ratingStar";
ratingcontrol.EmptyStarCssClass = "emptyStarRating";
ratingcontrol.WaitingStarCssClass = "emptyStarRating";
ratingcontrol.FilledStarCssClass = "filledStarRating";
ratingcontrol.Changed += new AjaxControlToolkit.RatingEventHandler(rating_Changed);
ratingcell.Controls.Add(ratingcontrol);
ratingcell.Attributes.Add("runat", "server");
ratingcell.Attributes.Add("onclick", "return false");
criteriumrij.Cells.Add(opvulcell);
criteriumrij.Cells.Add(criteriumtitel);
criteriumrij.Cells.Add(ratingcell);
evaluatietabel.Rows.Add(criteriumrij);
criteriumteller++;
}
}
}
evaluatietabel.BorderStyle = BorderStyle.None;
pnlEval.ContentTemplateContainer.Controls.Add(evaluatietabel);
Session["formulieractief"] = true;
pnlEval.Update();
pnlGegevens1.Update();
pnlGegevens2.Update();
}
I'm also adding the link to an image that shows my problem, so that you can see it for yourself:
We had the same issue recently and the problem was that the latest version of the AjaxControltoolkit seems to require a ToolkitScriptManager instead of the normal ScriptManager.
So just try changing your
asp:ScriptManager tag to
asp:ToolKitScriptManager or
ajax:ToolKitScriptManager
or whatever your namespace is.