<dx:ASPxGridView ID="GridViewTRY" runat="server" DataSourceID="SDSGridViewTRY" KeyFieldName="ID" OnInit="GridViewTRY_Init">
<Columns>
<dx:GridViewDataComboBoxColumn FieldName="PersonalFK" Caption="Personel Adı" ShowInCustomizationForm="True" >
<PropertiesComboBox TextField="PersonelName" ValueField="ID"></PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
</Columns>
</dx:ASPxGridView>
// on CodeBehind //
protected void GridViewTRY_Init(object sender, EventArgs e)
{
ASPxGridView gridView = (ASPxGridView)sender;
((GridViewDataComboBoxColumn)(gridView.Columns["PersonelFK"])).PropertiesComboBox.DataSource = myPersonalList;
}
31 Mayıs 2013 Cuma
30 Mayıs 2013 Perşembe
pass null parameter if Selectparameter is null
<asp:SqlDataSource ID="SDStry" runat="server" CancelSelectOnNullParameter="false"
SELECTCommand="SELECT * FROM tbFirma WHERE KisiFK=ISNULL(@KisiFK,KisiFK)">
<SelectParameters>
<asp:Parameter Name="KisiFK" ConvertEmptyStringToNull="true" />
</SelectParameters>
</asp:SqlDataSource>
2 Mayıs 2013 Perşembe
create special Sorting with c#
public class SortByNumber : Comparer<object>
{
public override int Compare(object x, object y)
{
var xParts = x.GetType().GetProperty("Code").GetValue(x, null).ToString().Split(new[] { '.' });
var yParts = y.GetType().GetProperty("Code").GetValue(y, null).ToString().Split(new[] { '.' });
xParts = xParts.Select((c) => { return (c == "" ? "0" : c); }).ToArray();
yParts = yParts.Select((c) => { return (c == "" ? "0" : c); }).ToArray();
int index = 0;
while (true)
{
bool xHasValue = xParts.Length > index;
bool yHasValue = yParts.Length > index;
if (xHasValue && !yHasValue)
return 1; // x bigger
if (!xHasValue && yHasValue)
return -1; // y bigger
if (!xHasValue && !yHasValue)
return 0; // no more values -- same
var xValue = int.Parse(xParts[index]);
var yValue = int.Parse(yParts[index]);
if (xValue > yValue)
return 1; // x bigger
if (xValue < yValue)
return -1; // y bigger
index++;
}
}
}
//*******//
public class ctry { public string Code{ get; set; }}
public void tryTest()
{
List<ctry> cList = new List<ctry>();
cList.Add(new ctry() { Code= "1.1" });
cList.Add(new ctry() { Code = "5" });
cList.Add(new ctry() { Code = "1.5" });
cList.Add(new ctry() { Code = "1.2" });
cList.Add(new ctry() { Code = "1.1.2" });
cList.Add(new ctry() { Code = "1" });
cList.Add(new ctry() { Code = "1.1.1" });
cList.Add(new ctry() { Code = "1.11" });
cList.Add(new ctry() { Code = "1.4" });
cList.Add(new ctry() { Code = "6" });
cList.Sort(new SortComparer ());
}
23 Kasım 2012 Cuma
mvc de $.ajax() ile multi delete
function f_MultiDelete()
{
if ($(".chList").size() > 0) {
var IDS = [];
$(".chList").each(function (i) {
if ($(this).attr('checked') == "checked" && $(this).attr('name') == "checkDelete") {
var ID = $(this).attr("vl");
IDS.push(ID);
}
});
if (IDS.length > 0) {
$.ajax({
type: "POST",url: Path, traditional:true, dataType:"json",
data: { 'IDList': IDS },
success: function (data) {
alert(data);
}
});
}
}
}
<input name="checkDelete" class="chList" vl="4" type="checkbox" />
<input name="checkDelete" class="chList" vl="3" type="checkbox" />
<input name="checkDelete" class="chList" vl="2" type="checkbox" />
<input name="checkDelete" class="chList" vl="5" type="checkbox" />
<div onclick="f_MultiDelete('/Admin/AGaleri/MultiDelete/')" class="btn btn-primary">Seçilileri Sil </div>
public ActionResult MultiDelete(IEnumerable<string> IDList)
{
//IDList parametresinden seçili ID lere ulaşabilirsiniz.
}
24 Ekim 2012 Çarşamba
asp.nette web servis kullanımı
Şimdilik .net 3.5 ta web servisi oluşturabiliyoruz. .net4.0 henüz desteklemiyor
Web servisini projemize 'tryWebService' adında ekliyoruz
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public bool firstService(string name,string lastName)
{
// yazmak istediğimiz kodlar
} // webmethod fonksiyonlarımız istediğimiz kadar çoğaltabiliriz.
}
Web servisini projemize 'tryWebService' adında ekliyoruz
var service1 = new tryWebService.Service1SoapClient();
service1.firstService("parametre1", "parametre2");
// yazdığımız tüm methodlara service1 örneğinden ulaşabiliriz.
28 Eylül 2012 Cuma
asp.net te windows service kullanımı
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
[OperationContract]
string GetUserInfo(int ID);
[OperationContract()]
IEnumerable<User> GetUserList();
}
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
[DataContract]
public class User
{
public int ID { get; set; }
public string name { get; set; }
public string password { get; set; }
public User() { }
public User(int _ID, string _name, string _password)
{
this.ID = _ID;
this.name = _name;
this.password = _password;
}
}
//**********************************//
servisi projemize ekledikten sonra
ServiceReference1.IService1 service = new ServiceReference1.Service1Client();
service örneğiyle yazdığımız metodlara ulaşabiliriz.
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
[OperationContract]
string GetUserInfo(int ID);
[OperationContract()]
IEnumerable<User> GetUserList();
}
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
[DataContract]
public class User
{
public int ID { get; set; }
public string name { get; set; }
public string password { get; set; }
public User() { }
public User(int _ID, string _name, string _password)
{
this.ID = _ID;
this.name = _name;
this.password = _password;
}
}
//**********************************//
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
public string GetUserInfo(int ID)
{
string sb = "";
User us = new User() { ID = 3, name = "hakan", password = "passsssssss" };
if (us.ID == ID)
{
sb = us.ID + " : " + us.name + " : " + us.password;
}
return sb;
}
public IEnumerable<User> GetUserList()
{
NSGenel.Genel.MesajGoster("ok");
return new List<User>() { new User() { ID = 3, name = "asdfsdf", password = "psdfsf" } };
//return (List<User>)(us.Add(new User { ID = 3, name = "dfgdfg", password = "passs" }));
}
}
//******************************//servisi projemize ekledikten sonra
ServiceReference1.IService1 service = new ServiceReference1.Service1Client();
service örneğiyle yazdığımız metodlara ulaşabiliriz.
11 Eylül 2012 Salı
asp.net mvc de bot yapımı
sayfadaki tüm <a> ve <a> tagı içerisindeki <img> taglarını çekmek için
//******************************************//
index sayfamız
<h2>Index</h2>
@{
List<string> datas = (List<string>)ViewData["datas"];
foreach(string s in datas.ToList())
{
<hr />
<label>@s.ToString()</label>
}
}
public ActionResult Index()
{
ViewData["datas"] = ss();
return View();
}
List<string> dataList = new List<string>();
private List<string> ss()
{
string Site = "http://shiftdelete.net/";
WebClient client = new WebClient();
Stream data = client.OpenRead(Site);
StreamReader reader = new StreamReader(data, Encoding.GetEncoding("utf-8"));
string datas = reader.ReadToEnd();
string pattern3 = "<a.*?href=.*?>(.*?(<img.*?>).*?)</a>";
MatchCollection mathcollection = System.Text.RegularExpressions.Regex.Matches(datas, pattern3);
foreach (Match match in mathcollection)
{
if (match.Value.ToString().Contains("<img"))
dataList.Add(match.Value);
}
return dataList;
}
//******************************************//
index sayfamız
<h2>Index</h2>
@{
List<string> datas = (List<string>)ViewData["datas"];
foreach(string s in datas.ToList())
{
<hr />
<label>@s.ToString()</label>
}
}
Etiketler:
asp.net,
asp.net mvc,
bot,
c#,
düzenli ifadeler,
regex
Kaydol:
Kayıtlar (Atom)