0

I'm trying to figure out how to select and view row details in my gridview. Basically I have a gridview with 9 columns, but 6 are hidden. When I click on a row, I want it to load those additional column values into my javascript so I can put them in a seperate table below. I feel like it's relatively simple but I'm just not understanding something and I was hoping I could be pointed in the right direction.

Here's some code I have if you need it.

<asp:GridView ID="BillabilityView" BackColor="White" runat="server" AutoGenerateColumns="false" CssClass="tbl">
    <columns> 
      <asp:boundfield datafield="UserName" headertext="User Name" /> 
      <asp:boundfield datafield="UserID" headertext="User ID" /> 
      <asp:boundfield datafield="HrsTLB" headertext="Billable Hours" /> 
      <asp:boundfield datafield="HrsTLNB" headertext="Nonbillable Hours" /> 
      <asp:boundfield datafield="HrsTL" headertext="Total Hours" /> 
      <asp:boundfield datafield="HrsExp" headertext="Expected Hours" /> 
      <asp:boundfield datafield="Billability" headertext="Billability" /> 
    </columns>
</asp:GridView>
1
  • I assume you have a datatable with 9 columns, but you are only binding 6 of them. Correct? Commented Jul 9, 2012 at 20:52

1 Answer 1

1

One way, though using a post-back, would be to use the OnSelectedIndexChanged event. It will pass you the row information in the callback and you could process and rebind any data you need.

One quick and dirty way to do it without a postback is to add a button or something to the columns collection. Use the onclick event to pass whatever information you need to a javascript method. Since you are using databinding, you could just use the <% Eval('FieldName') %> where fieldname is a column in your datatable to pass the data to your function. Another option is to use the RowDataBoundFunction to add html and javascript to the rows to do what you need.

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.