Ziggynet 0 Newbie Poster

Hi Everyone

I have two aspx pages that updates two values in a database.

I have an update button called Button1.

Button1 in the first page redirects to the second aspx page.

On the second page i want to select a value and then redirect to the first page.

How do i then get the value that is returned from the second Page? and the use it in Button1's method?

Response.Redirect("Pagetwo.aspx");
Label1.Text = Request.QueryString["sp"];
Ziggynet 0 Newbie Poster

Hi there here is a stupid question. I have created an update statement that updates a table that has null user id using a name as the identifier:

UPDATE dembel
SET userid = 8908
WHERE [Name] = 'o'reily'

However the the name already contains an apostrophe which causes a problem in sql, How can i write the name so that the apostrophe is part of the string itself.

Ziggynet 0 Newbie Poster

I now can export the datagridview to excel but i cannot export the headers from the datagridview into my excel document and when i open the excel document it does not autofit the data into the containing cells.

I tried adding them manually using

excelWorksheet.Cells[1,2] = "Heading Name";

But the excel document comes with an empty column at the end.

Ziggynet 0 Newbie Poster

Thanks a lot adatapost. The program is now up ad running correctly . thank you a lot for your help.

for (i = 0; i <= dtGrid.RowCount - 1; i++)
                    {
                        for (j = 0; j <= dtGrid.ColumnCount - 1; j++)
                        {
                            DataGridViewCell cell = dtGrid[j, i];
                            xSheet.Cells[i + 1, j + 1] = [B]cell.Value.ToString();[/B]
                        }
                    }
Ziggynet 0 Newbie Poster

Hey Developers

I have made an application that takes data from sql 2005 using a stored procedure and displays them on a datagridview. And then now i have written code to export the data to an excel file using Microsoft Interop and Excel Core Services.

When i click on the export button it throws a System.ArgumentOutOfRangeException error, which says index was out of range. Must be non negative and less than the size of the collection.

System.Windows.Forms.DataGridviewCellCollection.get_Item(Int32 index)

Here's my Code:

Excel._Application xApp;
                    Excel.Workbook xWork;
                    Excel.Worksheet xSheet;

                    object misValue = System.Reflection.Missing.Value;

                    xApp = new Excel.ApplicationClass();
                    xWork = xApp.Workbooks.Add(misValue);
                    xSheet = (Excel.Worksheet)xWork.Worksheets.get_Item(1);

                    int i = 0;
                    int j = 0;

                    for (i = 0; i <= dtGrid.Rows.Count; i++)
                    {
                        DataGridViewRow row = dtGrid.Rows[i];

                        for (j = 0; j <= row.Cells.Count; j++)
                        {
                            xApp.Cells[i + 1, j + 1] = row.Cells[j].ToString();
                        }
                    }


                    xWork.SaveAs(misValue, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                    xWork.Close(true, misValue, misValue);
                    xApp.Quit();

                    releaseObject(xSheet);
                    releaseObject(xWork);
                    releaseObject(xApp);