Showing posts with label Linq. Show all posts
Showing posts with label Linq. Show all posts

Saturday, August 6, 2011

Max Id of table find out by linq

Var idd = dt.bankdetails.Max(s => s.id);
        if (idd == null)
        {
            idd = 0;
        }
        bt.id = idd + 1;


Here dt is dataclass and bankdetails is table name.

Friday, August 5, 2011

Reterive Result Value In Linq (Using C#)



var s = dt.maxid().ToList();
        int id = 0; ;
        foreach (var a in s)
        {
           id= a.id.Value;
        }
       var aa= dt.insertuser(id, txtuname.Text, txtpas.Text, txtname.Text, txtcnum.Text, txtadd.Text, txtemail.Text,DateTime.Now.Date);
       string a1 = "";
       foreach (var aaa in aa)
       {
           a1 = aaa.sts.ToString();
       }
       ScriptManager.RegisterStartupScript(this, typeof(Page), "1", "alert('"+a1.ToString()+"')", true);