Selecting a column in a gridview

Discussion in 'ASP .Net' started by David, Apr 19, 2009.

  1. David

    David Guest

    Hi all,

    I am setting up a datatable (DT) that has something like 3 queries and lots
    of calculations to give me the desired result.

    When I have the results, I am then rotating that datatable 90 degrees (i.e.
    rows become columns, columns become rows). This works well.

    Now, when I bind the DT to a gridview, I want to have a linkbutton at the
    bottom of the calculated column(s). This linkbutton actually will go and get
    some PDF files, combine them and create a download. (The PDF stuff works
    well). What I need to do is to pass specific information from the column, so
    I know which PDF files to get.

    So, in normal circumstances, I would select a row (use a gridview select
    button), and use the selectedindex of the row (in fact, I am doing this
    elsewhere). So, how I would I do it for a column?

    Thanks for your help.

    --
    Best regards,
    Dave Colliver.
    http://www.AshfieldFOCUS.com
    ~~
    http://www.FOCUSPortals.com - Local franchises available
    David, Apr 19, 2009
    #1
    1. Advertising

  2. David

    Mr. Arnold Guest

    David wrote:
    > Hi all,
    >
    > I am setting up a datatable (DT) that has something like 3 queries and lots
    > of calculations to give me the desired result.
    >
    > When I have the results, I am then rotating that datatable 90 degrees (i.e.
    > rows become columns, columns become rows). This works well.
    >
    > Now, when I bind the DT to a gridview, I want to have a linkbutton at the
    > bottom of the calculated column(s). This linkbutton actually will go and get
    > some PDF files, combine them and create a download. (The PDF stuff works
    > well). What I need to do is to pass specific information from the column, so
    > I know which PDF files to get.
    >
    > So, in normal circumstances, I would select a row (use a gridview select
    > button), and use the selectedindex of the row (in fact, I am doing this
    > elsewhere). So, how I would I do it for a column?
    >
    > Thanks for your help.
    >


    Below is how you address a cell on a row.

    protected void gvDepartment_RowUpdating(object sender,
    GridViewUpdateEventArgs e)
    {
    TblContext = (DataTable)Session["TblContext"];

    GridViewRow row = gvDepartment.Rows[e.RowIndex];

    TblContext.Rows[row.DataItemIndex]["Name"] =
    ((TextBox)(row.Cells[2].Controls)[0]).Text.Trim();
    TblContext.Rows[row.DataItemIndex]["GroupName"] =
    ((TextBox)(row.Cells[3].Controls)[0]).Text.Trim();
    TblContext.Rows[row.DataItemIndex]["Delete"] =
    ((CheckBox)(row.Cells[4].Controls)[0]).Checked;

    ((CheckBox)(row.Cells[5].Controls)[0]).Checked = true;
    TblContext.Rows[row.DataItemIndex]["IsDirty"] =
    ((CheckBox)(row.Cells[5].Controls)[0]).Checked;

    TblContext.Rows[row.DataItemIndex]["IsNew"] =
    ((CheckBox)(row.Cells[6].Controls)[0]).Checked;

    gvDepartment.EditIndex = -1;

    BindData();
    }
    Mr. Arnold, Apr 19, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keithb
    Replies:
    2
    Views:
    1,137
  2. Greg Smith
    Replies:
    0
    Views:
    540
    Greg Smith
    Apr 12, 2007
  3. Keith G Hicks
    Replies:
    3
    Views:
    763
    Keith G Hicks
    Feb 18, 2008
  4. Tony Girgenti

    Gridview header sorted column dimmed after selecting it

    Tony Girgenti, Mar 21, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    758
    Tony Girgenti
    Mar 21, 2007
  5. Tony Girgenti

    Gridview header sorted column dimmed after selecting it

    Tony Girgenti, Mar 13, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    136
    Tony Girgenti
    Mar 13, 2007
Loading...

Share This Page