0

I have grid that I built this way

Name Amt    Invoice
Tom  100    bla bla
Liz  200    bla bla
Sue  300    bla bla
Edd  400    bla bla
Mat  500    bla bla

I made the invoice colum invisible (Visible = False)

in my code When user select row 1 I need to read invoice details in the code behind.

I tried this

    protected void grd_SelectedIndexChanged(object sender, EventArgs e)
    {

        string Invoice = grd.SelectedRow.Cells[3].Text;

but Invoice is always empty

it works when I change the visibility to True and I can read it then

but I dont want the user to see this column

how can I do that?

1
  • Are you wanting javascript or are you using c#? Also, you can hide a column in a gridview like this.dataGridView1.Columns["CustomerID"].Visible = false; Commented Jul 28, 2020 at 21:20

1 Answer 1

1

By setting column Visible = True, the data is emitted from the viewstate. Therefore the data does not appear on postback. To get around this, you can set Visible = False and hide the column using css. Alternativly use a hidden input.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.