J
JLuv
What i want to do is take the checked data from a datagrid, send it to
a table, then show that table on an Excel Spreadsheet. Here is a little
bit of my code...
//adminProgress.aspx
<aspataGrid ID="pGrid" runat="server" AutoGenerateColumns="false"
AllowSorting="true">
<Columns>
<asp:TemplateColumn HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="check" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="lastName"
HeaderText="Last Name" />
<asp:BoundColumn DataField="firstName"
HeaderText="First Name" />
<asp:BoundColumn DataField="phoneNum"
HeaderText="Work Number" />
</Columns>
</aspataGrid>
//code behind to find selected items
private void buildTable()
{
tblTom.ID = "tblSelection";
foreach (DataGridItem dgItem in pGrid.Items)
{
if (((CheckBox)dgItem.FindControl("check")).Checked)
{
TableRow tRow = new TableRow();
TableCell tCell = new TableCell();
tblTom.Rows.Add(tRow);
tRow.Cells.Add(tCell);
tCell.Text = "CHECKED";
//tCell.Text = dSet.Tables[0].Rows[0].ToString();
}
}
//code behind to export from adminProgress.aspx to SpreadSheet.aspx
void export_Click(object sender, EventArgs e)
{
buildTable();
Server.Transfer("SpreadSheet.aspx");
}
//code behind SpreadSheet.aspx to show table from adminProgress.aspx
protected void Page_Load(object sender, EventArgs e)
{
adminProgress progressPage = (adminProgress)Context.Handler;
this.Controls.Add(progressPage.tblTom);
}
What happens is, when i select the wanted names, and click "Export" I
get a prompt to save/open and Excel spreadsheet (which is good). but
the spread sheet is empty(which is bad).
Any help?
oh, i inserted these into the top of SpreadSheet.aspx...
<%@ Reference Page="~/adminProgress.aspx" %>
<% Response.ContentType = "application/vnd.ms-excel"; %>
a table, then show that table on an Excel Spreadsheet. Here is a little
bit of my code...
//adminProgress.aspx
<aspataGrid ID="pGrid" runat="server" AutoGenerateColumns="false"
AllowSorting="true">
<Columns>
<asp:TemplateColumn HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="check" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="lastName"
HeaderText="Last Name" />
<asp:BoundColumn DataField="firstName"
HeaderText="First Name" />
<asp:BoundColumn DataField="phoneNum"
HeaderText="Work Number" />
</Columns>
</aspataGrid>
//code behind to find selected items
private void buildTable()
{
tblTom.ID = "tblSelection";
foreach (DataGridItem dgItem in pGrid.Items)
{
if (((CheckBox)dgItem.FindControl("check")).Checked)
{
TableRow tRow = new TableRow();
TableCell tCell = new TableCell();
tblTom.Rows.Add(tRow);
tRow.Cells.Add(tCell);
tCell.Text = "CHECKED";
//tCell.Text = dSet.Tables[0].Rows[0].ToString();
}
}
//code behind to export from adminProgress.aspx to SpreadSheet.aspx
void export_Click(object sender, EventArgs e)
{
buildTable();
Server.Transfer("SpreadSheet.aspx");
}
//code behind SpreadSheet.aspx to show table from adminProgress.aspx
protected void Page_Load(object sender, EventArgs e)
{
adminProgress progressPage = (adminProgress)Context.Handler;
this.Controls.Add(progressPage.tblTom);
}
What happens is, when i select the wanted names, and click "Export" I
get a prompt to save/open and Excel spreadsheet (which is good). but
the spread sheet is empty(which is bad).
Any help?
oh, i inserted these into the top of SpreadSheet.aspx...
<%@ Reference Page="~/adminProgress.aspx" %>
<% Response.ContentType = "application/vnd.ms-excel"; %>