Here is my aspx code:
=============
<%@ Page language="c#" Codebehind="Web Form3.aspx.cs" AutoEventWireup ="false"
Inherits="PDM.e xcel.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3 </title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="C#" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
</HEAD>
<body text="black" bgColor="silver " MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px;
POSITION: absolute; TOP: 72px" runat="server"
GridLines="Vert ical" AutoGenerateCol umns="False"
CellPadding="3" BackColor="Whit e" BorderWidth="1p x" BorderStyle="No ne"
BorderColor="#E 7E7FF">
<SelectedItemSt yle Font-Bold="True" ForeColor="#F7F 7F7"
BackColor="#738 A9C"></SelectedItemSty le>
<AlternatingIte mStyle
BackColor="#F7F 7F7"></AlternatingItem Style>
<ItemStyle ForeColor="#4A3 C8C"
BackColor="#E7E 7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F 7F7"
BackColor="#4A3 C8C"></HeaderStyle>
<FooterStyle ForeColor="#4A3 C8C"
BackColor="#B5C 7DE"></FooterStyle>
<Columns>
<asp:BoundColum n DataField="stri ng_id"
ReadOnly="true" HeaderText="Str ing ID"></asp:BoundColumn >
<asp:BoundColum n DataField="stri ng" ReadOnly="true"
HeaderText="Str ing"></asp:BoundColumn >
</Columns>
<PagerStyle HorizontalAlign ="Center" ForeColor="Blac k"
BackColor="#999 999" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid><a sp:dropdownlist id="Language_Dr opDownList"
style="Z-INDEX: 102; LEFT: 296px; POSITION: absolute; TOP: 24px"
runat="server"
AutoPostBack="T rue"></asp:dropdownlis t><asp:label id="Label1"
style="Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 24px"
runat="server"
Width="248px" Font-Bold="True">Cho ose Your Language To
Convert:</asp:label><asp: button id="Button1" style="Z-INDEX: 104; LEFT:
392px; POSITION: absolute; TOP: 24px" runat="server"
Text="Submit"></asp:button></form>
</body>
</HTML>
and asp.cs
======
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;
using System.Xml.Xsl;
using System.Xml;
namespace PDM.excel
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
public class WebForm3 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
public SqlConnection conDB = new SqlConnection() ;
static public string[] LanguageStr =
{
"English","Fren ch","Spanish" };
static public string[] DropDownListStr =
{
"Language_DropD ownList"};
protected System.Web.UI.W ebControls.Drop DownList
Language_DropDo wnList;
protected System.Web.UI.W ebControls.Labe l Label1;
protected System.Web.UI.W ebControls.Butt on Button1;
static public string[][] AddStrArray =
{
LanguageStr};
private void Fill_DropDownLi st()
{
for (int i = 0; i < DropDownListStr .Length; i++)
{
string CtrlName= DropDownListStr[i];
DropDownList MyList =
(DropDownList)P age.FindControl (CtrlName);
// Populate all the checkboxes
string[] ToPopulate = AddStrArray[i];
for (int j = 0; j < ToPopulate.Leng th; j++)
{
MyList.Items.Ad d(new ListItem(ToPopu late[j],
j.ToString()));
}
}
}
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
Fill_DropDownLi st();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Language_D ropDownList.Sel ectedIndexChang ed += new
System.EventHan dler(this.Langu age_DropDownLis t_SelectedIndex Changed);
this.Button1.Cl ick += new
System.EventHan dler(this.Butto n1_Click);
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
public DataSet DataToExcel = new DataSet();
public void BindGrid (int index)
{
conDB.Connectio nString = "data
source=10.195.1 7.7;database=de vnew;uid=bounaa jak;pwd=ehsfirs t;packet
size=4096";
SqlDataAdapter da = new SqlDataAdapter( "Select string_id,
string from pdm_translation s where language_id = 1 and string_id not in
(select string_id from pdm_translation s where language_id = " +
index.ToString( ) + ") ", conDB);
da.Fill(DataToE xcel, "DataToExce l");
Session["Tabla"] = Language_DropDo wnList.Selected Item.Text;
DataToExcel.Wri teXml(Server.Ma pPath(Session["Tabla"] +
".xml"));
DataGrid1.DataS ource = DataToExcel;
DataGrid1.DataB ind();
// Get row count
int nRowCount = DataToExcel.Tab les["DataToExce l"].Rows.Count;
// Store Row count in Session variable
Session["RowCount"] = nRowCount;
}
private void Language_DropDo wnList_Selected IndexChanged(ob ject
sender, System.EventArg s e)
{
int getSelectedInde x = Language_DropDo wnList.Selected Index+1;
BindGrid(getSel ectedIndex);
}
public void DataGridToExcel (DataGrid Export,HttpResp onse Response)
{
// Set the Response mime type for excel
Response.Conten tType = "applicatio n/vnd.ms-excel";
// Create a String Writer
System.IO.Strin gWriter stringWrite = new
System.IO.Strin gWriter();
Response.Charse t = "";
this.EnableView State = false;
System.IO.Strin gWriter tw = new System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter hw = new
System.Web.UI.H tmlTextWriter(t w);
DataGrid1.Rende rControl(hw);
Response.Write( tw.ToString());
Response.End();
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
DataGridToExcel (DataGrid1, Response);
}
}
}
--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/