Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Does anyone know what property I can use to retrieve the value in a datagrid cell? Below I have a button column that has a "Select" link. When I click it I want to retrieve a value in one of the columns and assign it to a variable. Can someone help. Thanks

 

James

 

 

 

<asp:DataGrid id="lstResults" runat="server" Visible="False" PageSize="100" AutoGenerateColumns="False" Width="60%" HorizontalAlign="Center" CellPadding="0">

<HeaderStyle Font-Bold="True" HorizontalAlign="Center"></HeaderStyle>

<Columns>

<asp:ButtonColumn Text="Select" CommandName="Select">

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>

<ItemStyle Wrap="False"></ItemStyle>

</asp:ButtonColumn>

<asp:BoundColumn DataField="twp" HeaderText="TWP">

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>

<ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="wbs" HeaderText="WBS">

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>

<ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="Resource" HeaderText="Resource">

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>

<ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="camname" HeaderText="CAM Name">

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>

<ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="boe" HeaderText="BOE Desc">

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>

<ItemStyle HorizontalAlign="Center" Wrap="True" VerticalAlign="Top"></ItemStyle>

</asp:BoundColumn>

</Columns>

</asp:DataGrid>

Posted

Ok I got it to work. What I did was I change the button column to a EditCommand Column and name the edit text "Select." When the "Select" link was press I placed the record in edit mode then I assign the variables with values form the textboxes. I did not disable the edit mode since I redirected the user. If you want you can disable the edit mode on the last line. The user will never know that it was in edit mode. Codes below.

 

Public Sub grdResults_Edit(ByVal Source As Object, ByVal E As DataGridCommandEventArgs)

 

lstResults.EditItemIndex = E.Item.ItemIndex

BindData()

 

Session("TWP") = E.Item.Cells(2).Text

Session("WBS") = E.Item.Cells(3).Text

Session("Resource") = E.Item.Cells(5).Text

Session("search") = "T"

If E.CommandSource.text = "Detail" Then

Response.Redirect("LaborDetails.aspx")

 

Else

Response.Redirect("NewLaborEst.aspx")

End If

End Sub

 

James

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...