0

I am having a GridView in my page , I want that when a particular row is clicked I want the cell value of that particular row.Currently I get that that value by using something like this ,

protected void SearchRecordGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {


                e.Row.Attributes.Add("onclick", "location='ModifyCustomerByCategory.aspx?ApplicationNo=" + e.Row.Cells[0].Text + "'");
            }

        }

Currently I am passing that value as a parameter to the page , can any body tell how can I store that value in a variable or , atleast on click I assign it to a hidden field. Thanks for any suggestions.

2 Answers 2

2

Try this link. It runs through everything you will need, and on the gridview selectedindexchanged event you can reference the value with GridView.SelectedRow.Cells[0].Text or the control containing the value Gridview.SelectedRow.FindControl("[Control Name]")

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

4 Comments

thanks a lot , could you tell me what does javascript:_doPostBack do , any idea?
@freebird Well, without going too far into it, it causes the client to request a new page from the server. Further Reading
it helped but the selectedindexchanged event is not firing for me.
@freebird did you want to post the code or work through yourself?
1

In row data bound simply save that value and use it

int appno =  CInt(e.Row.Cells[0].Text)

and if you want to use this value to next page

int appno = CInt(Request.Querystring("ApplicationNo"))

1 Comment

thank you , but how will I know which row was clicked with this

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.