Posts

Showing posts from September, 2011

How to edit gridview in asp.net

public partial class _Default : System.Web.UI.Page {     SqlConnection cn = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=test;integrated security=true;");     SqlDataAdapter adp;     DataSet ds = new DataSet();     protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             ViewState["exp"] = "name";             datab();         }     }     private void datab()     {         adp = new SqlDataAdapter("select * from emp order by " + ViewState["exp"].ToString(), cn);         adp.Fill(ds, "first");         GridView1.DataSource = ds;         GridView1.DataBind();     }     protected void GridView1_RowEditing(...

Add Month to a date in javascript

function getNextScheduledDate() {             var date = document.getElementById('<%= txtDate.ClientID %>');             var arry = new Array();             arry[1] = document.getElementById('<%=txtDate.ClientID %>').value;             var ArrDoj = arry[1].split("/");             var myDate = new Date(ArrDoj[2], ArrDoj[1], ArrDoj[0]);             //get month and add three month             myDate.setMonth(myDate.getMonth() + 3);             //get date             var strday = myDate.getDate(); //.getDay();             var strMonth = myDate.getMonth();             //get year             var strYear = myDate.getFullYear(); ...

Multiple File Upload

HttpFileCollection uploadFilCol = Request.Files; 02. for ( int i=0;i<uploadFilCol.Count;i++) 03. { 04.    HttpPostedFile file = uploadFilCol[i]; 05.    string fileExt = Path.GetExtension(file.FileName).ToLower(); 06.    string fileName = Path.GetFileName(file.FileName); 07.    if (fileName != string .Empty) 08.    { 09.      try 10.      { 11.        if (fileExt == ".jpg" || fileExt == ".gif" ) 12.        { 13.          file.SaveAs(Server.MapPath( "./Images/" ) + fileName); 14.          this .ShowMessage( " " + fileName + " Successfully Uploaded" ,i); 15.        } 16.        else 17.        { 18.          file.SaveAs(Server....

Fill Gridview using datatable in asp.net

 DataTable dt = new DataTable();         if (Session["data"] != null)         {             dt = (DataTable)Session["data"];         }         else         {             dt.Columns.Add(new DataColumn("product", typeof(string)));             dt.Columns.Add(new DataColumn("quantity", typeof(Int32 )));             dt.Columns.Add(new DataColumn("price", typeof(Single )));             dt.Columns.Add(new DataColumn("pdate", typeof(DateTime )));         }         DataRow dr;         dr = dt.NewRow();         dr["product"] = TextBox1.Text;         dr["quantity"] = Convert.ToInt32( TextBox2.Text);         dr[...

hey frds I want to fetch data from a column and display it as a row that's called pvorting !!!! may u pls help me out?

private DataTable PivotTable(DataTable origTable) { DataTable newTable = new DataTable(); DataRow dr = null; //Add Columns to new Table -------------------------- ---- for (int i = 0; i <= origTable.Rows.Count; i++) { newTable.Columns.Add(new DataColumn(origTable.Colum ns[i].ColumnName, typeof(String))); } //Execute the Pivot Method for (int cols = 0; cols < origTable.Columns.Count; cols++) { dr = newTable.NewRow(); for (int rows = 0; rows < origTable.Rows.Count; rows++) { if (rows < origTable.Columns.Count) { dr[0] = origTable.Columns[cols].Co lumnName; // Add the Column Name in the first Column dr[rows + 1] = origTable.Rows[rows][cols] ; } } newTable.Rows.Add(dr); //add the DataRow to the new Table rows collection } return newTable; -------------------------- -------------------------- ---------------------- This method is used to fill grid view -------------------------- ---------------------- private void BindGridView() { try { string...