Solve Error : ASP.NET runtime error: Could not load file or assembly ‘AjaxControlToolkit, Version=1.0.10920.32880
Add following XML to the eScrum web.conifg file after the </configSections> close tag. Afterward, update the newVersion attribute to the version of the control toolkit that you are using.
<runtime>
<assemblyBinding xmlns=”urn
chemas-microsoft-com:asm.v1″>
<dependentAssembly>
<assemblyIdentity name=”AjaxControlToolkit”
publicKeyToken=”28f01b0e84b6d53e”
culture=”neutral”/>
<bindingRedirect oldVersion=”1.0.10301.0″ newVersion=”1.0.xxxxx.0″/>
</dependentAssembly>
</assemblyBinding>
</runtime>
ref: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1913881&SiteID=1
cool tutor (n-tier)
http://www.covertcoder.com/Tutorial.aspx?TopicAreaID=AfmUsz/RcY/aN0GtV+UaCsl1p3mJCHjdzkYCC7PvVpIA
Sorting with DataView
DataView dv = SapNewdt.DefaultView;
string sortExpr = ” Sent_SAP_Date ASC”;
//TableManager.HRTxnSAPSummary.SENT_SAP_DATE + ” , ” + TableManager.HRTxnSAPSummary.PROC_NAME + ” ASC”;
dv.Sort = sortExpr;
SapNewdt = dv.ToTable();
DataSet SapDs = new DataSet();SapDs.Tables.Add(SapNewdt);
return SapDs;
optimize data from calling webservice
DataTable HrDt = mHRTxnSAPData.ListDetail_OF_SentDocToSAP(comp_code, module, start_sap_date, end_sap_date
, start_doc_date, end_doc_date, crem_type, Process_name, success, type);
foreach (DataRow dr in HrDt.Rows)
{
//save to arrayList
strPin = dr[TableManager.WFCremation.PIN].ToString();
if (mList.IndexOf(strPin) == -1)
{
mList.Add(strPin);
if (type == “CR”)
{
strPin = dr[TableManager.WFCremation.HR_PIN].ToString();
if (mList.IndexOf(strPin) == -1)
mList.Add(strPin);
}
}
//save to hash(org info) –
strOrgInfo = dr[TableManager.WFCremation.NEAR_ORG_ID].ToString();
if (strOrgInfo != string.Empty)
{
if (!hashOrgInfo.ContainsKey(strOrgInfo))
{
OrgDs = mOMEHRService.GetOrgInfobyOrgCode(strOrgInfo);
if (OrgDs.Tables[0].Rows.Count > 0)
hashOrgInfo[strOrgInfo] = OrgDs.Tables[0].Rows[0][TableManager.Employee.ORG_DESC].ToString();
}
}
}
for (int a = 0; a < mList.Count; a++)
{
if (strPin != string.Empty)
strPin = strPin + “,”;
strPin = strPin + mList[a].ToString();
}
//call ws for employee profile –
dsProfile = mOMEHRService.ListEmployeeProfileByPIN(strPin);
———- calling ——————
DataRow[] drProfile;
drProfile = dsProfile.Tables[0].Select(” PIN=’” + HrDr[TableManager.WFCremation.PIN].ToString() + “‘”);if (drProfile.Length != 0){
Pin_name = drProfile[0]["THFIRSTNAME"].ToString() + ” “ + drProfile[0]["THLASTNAME"].ToString();Position = drProfile[0][
TableManager.Employee.POSI_DESC].ToString();}
asp.net repeater
<asp:Repeater id=”Repeater1″ runat=”server”> <HeaderTemplate> <table border=”1″> <tr bgcolor=”#ffcc99″> <th>ID</th> <th>First Name</th> <th>Last Name</th> <th>Address</th> </tr> </HeaderTemplate> <ItemTemplate> <tr bgcolor=”#ffcccc”> <td><%# DataBinder.Eval(Container.DataItem, “au_id”) %></td> <td><%# DataBinder.Eval(Container.DataItem, “au_fname”) %></td> <td><%# DataBinder.Eval(Container.DataItem, “au_lname”) %></td> <td><%# DataBinder.Eval(Container.DataItem, “address”) %></td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr bgcolor=”#ccff99″> <td><%# DataBinder.Eval(Container.DataItem, “au_id”) %></td> <td><%# DataBinder.Eval(Container.DataItem, “au_fname”) %></td> <td><%# DataBinder.Eval(Container.DataItem, “au_lname”) %></td> <td><%# DataBinder.Eval(Container.DataItem, “address”) %></td> </tr> </AlternatingItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>
web.config
As an example, let’s examine this minimal web.config with an appSetting entry to hold our connection string:
1 <?xml version=”1.0″ encoding=”utf-8″ ?>
2 <configuration>
3
4 <system.web>
5 <compilation defaultLanguage=”c#” debug=”true” />
6 </system.web>
7
8 <appSettings>
9 <add key=”ConnectionInfo” value=”server=(local);database=Northwind;Integrated Security=SSPI” />
10 </appSettings>
11
12 </configuration>
To read the key we use the ConfigurationSettings class from the System.Configuration namespace, as shown below.
12 private void Page_Load(object sender, EventArgs e)
13 {
14 string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
15 using(SqlConnection connection = new SqlConnection(connectionInfo))
16 {
17 connection.Open();
18
19 // perform work with connection
20
21 }
22 }
– ถ้าจะใช้ ConnectionStrings ———————–
/*<?xml version=”1.0″?><configuration>
<connectionStrings>
<add name=”Northwind”
connectionString=”server=localhost;uid=sa;pwd=thiru;
database=northwind”>
</add>
</connectionStrings>
*
<system.web>
</system.web>
</configuration>*/
public string cnStr = System.Configuration.ConfigurationManager.ConnectionStrings["connectionStrings"].ToString();
——————————————————————-
Encapsulation
Let’s abstract away the source of the connection string using a class with a static property.
1 using System.Configuration;
2
3 namespace aspnet.config
4 {
5 public class Configuration
6 {
7 public static string ConnectionInfo
8 {
9 get
10 {
11 return ConfigurationSettings.AppSettings["ConnectionInfo"];
12 }
13
14 }
15 }
16 }
Now our Page_Load method looks like the following.
11 private void Page_Load(object sender, EventArgs e)
12 {
13 using(SqlConnection connection = new SqlConnection(Configuration.ConnectionInfo))
14 {
15 connection.Open();
16
17 // perform work with connection
18
19 }
20 }
The changes we made to the above code were relatively small - but powerful. Now the Page_Load function doesn’t know where the connection string comes from. We could easily change the ConnectionInfo property to retrieve the string from a different source without modifying any other code in the application. We also no longer have to remember the key string and hard code the string at various points in the application. Instead, we can utilize Visual Studio Intellisense when accessing the Configuration class to find the setting we need. The key value only appears once – inside the ConnectionInfo property – so we could again change the key name in the web.config and have only one line of code to update.