Sunday, 10 February 2013

Working With DateTime In SQL and C#

Date Time Format In C# and SQL







In ASP.net C#

compare two date like TextBoxToDate and TextBoxToDate

DateTime org = DateTime.ParseExact(TextBoxToDate .Text,"dd/MM/yyyy",null);
DateTime enter = DateTime.ParseExact(TextBoxToDate.Text, "dd/MM/yyyy", null);

if(enter.Date<org.Date)
        {
//do what you wish          
        }


       

Monday, 4 February 2013

Selection In GridView With CheckBoxes


CheckBoxes Wise Selection In GridView in just 3 steps







1)In ASPX side
 your grid view must contain DataKeyNames
 and checkbox under templatefield

 <asp:GridView ID="GridViewtemp" runat="server"   DataKeyNames="Person_Id">



2)Now you have above grid where so many rows are avail and each row has a checkbox in it(as we placed a checkbox in templatefield's item template)

now when user click on these checkboxes and make out his selection we will provide him further a button 'btnselect' which will again bind a grid and show you only those selected row which were checked previously.

3)So On that btnselect_click event




In C# On Button Click

 protected void btnselect_Click(object sender, EventArgs e)
     {
       

    
             for (int i = 0; i < GridViewtemp.Rows.Count; i++)
             {
                 if (((CheckBox)GridViewtemp.Rows[i].FindControl("chkSONo")).Checked == true)
                 {
                     soid = ((Label)GridViewtemp.Rows[i].FindControl("
lblPersonid")).Text;


                     if (value == "")
                     {
                         value = soid;
                     }
                     else
                     {
                         value = value + "," + soid;
                     }


                 }

             }
             BindItemGrid(soid);
            
       
     }
     public void BindItemGrid(string Key)
     {
         query = " select * from tb_Stamping  where   [Person_Id] in (" + value + ")";
         SqlDataAdapter adp = new SqlDataAdapter(query, con);
         DataSet ds = new DataSet();
         adp.Fill(ds);
         gvselectcontent.DataSource = ds;
         gvselectcontent.DataBind();

     }

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...