codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  C# and EXCEL question saving a file saving the the first column as read only  macsgirl at 22:25 on Thursday, January 06, 2005
 

in the Button1_Click I need to make the 1st column saved as readonly.

How can I do this?

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml.Xsl;
using System.Xml;

namespace PDM.excel
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
public SqlConnection conDB = new SqlConnection();

static public string[] LanguageStr =
{
"English","French","Spanish"};
static public string[] DropDownListStr =
{
"Language_DropDownList"};
protected System.Web.UI.WebControls.DropDownList Language_DropDownList;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;

static public string[][] AddStrArray =
{
LanguageStr};

private void Fill_DropDownList()
{
for (int i = 0; i < DropDownListStr.Length; i++)
{
string CtrlName= DropDownListStr;
DropDownList MyList = (DropDownList)Page.FindControl(CtrlName);
// Populate all the checkboxes
string[] ToPopulate = AddStrArray;
for (int j = 0; j < ToPopulate.Length; j++)
{
MyList.Items.Add(new ListItem(ToPopulate[j], j.ToString()));
}
}
}

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
Fill_DropDownList();


}

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Language_DropDownList.SelectedIndexChanged += new System.EventHandler(this.Language_DropDownList_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public DataSet DataToExcel = new DataSet();



private void Language_DropDownList_SelectedIndexChanged(object sender, System.EventArgs e)
{
int getSelectedIndex = Language_DropDownList.SelectedIndex+1;
conDB.ConnectionString = "data source=10.195.17.7;database=devnew;uid=bounaajak;pwd=ehsfirst;packet size=4096";
SqlDataAdapter da = new SqlDataAdapter("Select string_id, string from pdm_translations where language_id = 1 and string_id not in (select string_id from pdm_translations where language_id = " + getSelectedIndex.ToString() + ") ", conDB);
da.Fill(DataToExcel, "DataToExcel");
Session["Tabla"] = Language_DropDownList.SelectedItem.Text;
DataToExcel.WriteXml(Server.MapPath(Session["Tabla"] + "/forum/.xml"));
DataGrid1.DataSource = DataToExcel;
DataGrid1.DataBind();
Language_DropDownList.Visible = false;

}

private void Button1_Click(object sender, System.EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(Session["Tabla"] + "/forum/.xml"));
XmlDataDocument xdd = new XmlDataDocument(ds);
XslTransform xt = new XslTransform();
xt.Load(Server.MapPath("Excel.xsl"));
xt.Transform(xdd, null, Response.OutputStream);
Response.End();
}




}
}


  Re: C# and EXCEL question saving a file saving the the first column as read only  pahioman at 12:36 on Sunday, March 13, 2005
 

I'm intrigued by your code, and wonder if you can send me your .xls file. I'd like to try and load and run your code. I'm not sure what your code is doing. Specifically the FillDropDownList() method and button_1 click method.

What is the AddStrArray doing? You say Populate the checkboxes? What checkboxes?

Also I'd need the devnew database.

  Re: C# and EXCEL question saving a file saving the the first column as read only  mreddy at 18:41 on Tuesday, March 15, 2005
 

Hi,
Wow this is good. Looks like you have good knowledge in c#. I am 3rd student and i just started this c#. I need some help, although my question is not relavant to your post, please help me.

I have a project to do student registration. I need some help, it would be great if you can help me thru this question.

I have " student registration" database where student is the table name and id , password, name.. so on are the attributes.

In visual studio c# i have form where there is "new student" and "Current student" radio buttons and "enter" button. When we enter as new student it will ask for userid and password.

When the user enter the id and password it should first check that the id is not existing and then save in student table, so that next time the user can enter as current student. Userid is saved in id column of student table.


Can anyone please help me thru this. Any help would be appreciated. pleaseeeeeeee

Thank you,

<Added>

sorry lil change,
When the user enter the id and password it should first check that the id is not existing if its not existing then save in student table, so that next time the user can enter as current student. Userid is saved in id column of student table.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Data
•  sort with javascript
•  setting default frame for an ASP.net app
•  Password creation and password protected site
•  Script For Customers To Upload Images To My Server
•  next and previous buttons
•  Re: C# and EXCEL question saving a file saving the the first column as read only
•  Windows Authentication using LDAP get user first name
•  Javabeans incorporating sql query.


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005