This is a migrated thread and some comments may be shown as answers.

radgrid cannot get value in cell

2 Answers 264 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MVeranis
Top achievements
Rank 1
MVeranis asked on 09 Dec 2010, 08:50 PM
i have a radgrid - i want to access the cell values and put to a textbox. when i click on the row (and fire the ItemCommand event), the cell values are  
please help. thanks.

<telerik:RadGrid  ID="rgShip" runat="server" AutoGenerateColumns="false" Skin="Windows7"
 AllowMultiRowSelection="false" OnNeedDataSource="LoadMethods">
      <MasterTableView DataKeyNames="ship_meth_id" >
        <Columns>
            <telerik:GridButtonColumn DataTextField="ship_meth_desc" CommandName="Select" ItemStyle-HorizontalAlign="Left" 
            HeaderText="Shipping Method" UniqueName="shipmethdesc"></telerik:GridButtonColumn>
                                 
        </Columns>
      </MasterTableView>
</telerik:RadGrid>

code behind:
Protected Sub LoadMethods()
        Try
            Dim ds As dataset
            ds = DBSvc.GetDataset, "sp_Ship_Meth_SEL")
  
            Dim dv As DataView
            dv = ds.Tables(0).DefaultView
            dv.Sort = "ship_meth_desc"
  
            rgShip.DataSource = dv
  
  
    Protected Sub rgShip_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgShip.ItemCommand
        Try
            If e.CommandName = "Select" Then
                Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)
                txtMethod.Text = dataItem("shipmethdesc").Text

TXTMETHOD.TEXT IS &NBSP;  i cannot get the values of the cell text's. the grid displays fine with the correct entries but i cannot get to the cell text to move to a textbox.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2010, 05:57 AM
Hello,

 Since you are using GridButton column, you need to access the control first and then get the Text like below. 

CodeBehind:
If e.CommandName = "Select" Then
 
    Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
    Dim btn As LinkButton = TryCast(item("ColumnUniqueName").Controls(0), LinkButton)
    TextBox1.Text = btn.Text
End If

Thanks,
Shinu.
0
MVeranis
Top achievements
Rank 1
answered on 10 Dec 2010, 02:14 PM
dah...thanks!!! i was so engrossed in learning the radgrid...i overlook what kind of column it was!
Tags
Grid
Asked by
MVeranis
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
MVeranis
Top achievements
Rank 1
Share this question
or