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

Detailed table doesn't Bind

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prajeesh
Top achievements
Rank 1
Prajeesh asked on 06 Jan 2012, 10:05 AM
Hi all,
Please help me in this thread
I am using telerik radgrid control,
No issue in master table, datas are bind comfortably
my problem is
radgrid contain one detailed table
I am using DetailTableDataBind event to bind data
the datasource in detail table have the values but it does not shows while running .

here is my design source

<

 radG:RadGrid ID="dgrdResults" runat="server" Width="100%" AllowSorting="true"

 RadControlsDir="../Assets/RadControls/" GridLines="None" SkinsPath="../Assets/RadControls/Grid/Skins"

 EnableAJAX="true" AutoGenerateColumns="false" >

 <ExportSettings ExportOnlyData="false" IgnorePaging="true" OpenInNewWindow="true" />

 <PagerStyle Mode="NextPrevAndNumeric" />

 <MasterTableView DataKeyNames="RecipientId">

 <ExpandCollapseColumn Visible="false">

 <HeaderStyle Width="19px" />

 </ExpandCollapseColumn>

 <RowIndicatorColumn Visible="false">

 <HeaderStyle Width="20px" />

 </RowIndicatorColumn>

 <NoRecordsTemplate>

 <asp:Label ID="lblNoRecordsFound" runat="server" Text="No records bind">

 </asp:Label>

 </NoRecordsTemplate>

 <DetailTables >

 

 

<radG:GridTableView DataKeyNames ="ID" runat="server">

 

 

<ParentTableRelation >

 

 

<radG:GridRelationFields DetailKeyField="ID" MasterKeyField ="RecipientId" />

 

 

</ParentTableRelation>

 

 

<NoRecordsTemplate>

 

 

<asp:Label runat="server" ID="lblNorecord" Text="No records bind">

 

 

</asp:Label>

 

 

</NoRecordsTemplate>

 

 

<Columns>

 

 

<radG:GridBoundColumn HeaderText="Name" DataField="Name">

 

 

</radG:GridBoundColumn>

 

 

</Columns>

 

 

</radG:GridTableView>

 

 

</DetailTables>

 <Columns>

 <radG:GridTemplateColumn >

 <Headerstyle width="20px" />

 <Headertemplate>

 <asp:CheckBox runat="server" ID="All" OnCheckedChanged="SelectAllContacts" Autopostback="True" />

 </Headertemplate>

 <ItemTemplate>

 <asp:CheckBox runat="server" ID="Contact" />

 </ItemTemplate>

 </radG:GridTemplateColumn>

 <radG:GridBoundColumn DataField ="Email" HeaderText="<%$ Resources:ToolTextEmail, Recipient_Email %>" UniqueName="Email"></radG:GridBoundColumn>

 <radG:GridBoundColumn DataField="FirstName" HeaderText="<%$ Resources:ToolTextEmail, Recipient_FirstName %>" UniqueName="First Name"></radG:GridBoundColumn>

 <radG:GridBoundColumn DataField="LastName" HeaderText="<%$Resources:ToolTextEmail, Recipient_LastName %>" UniqueName="Lase Name"></radG:GridBoundColumn>

 <radG:GridBoundColumn DataField="Address1" HeaderText="<%$Resources:ToolTextEmail, Recipient_Address1 %>" UniqueName="Address1"></radG:GridBoundColumn>

 <radG:GridBoundColumn DataField="Company" HeaderText="<%$Resources:ToolTextEmail, Recipient_Company %>" UniqueName="Company"></radG:GridBoundColumn>

 <radG:GridBoundColumn DataField="City" HeaderText="<%$Resources:ToolTextEmail, Recipient_City %>" UniqueName="City"></radG:GridBoundColumn>

 <radG:GridBoundColumn DataField="State" HeaderText="<%$Resources:ToolTextEmail, Recipient_State %>" UniqueName="State"></radG:GridBoundColumn>

 </Columns>

 </MasterTableView>

 </radG:RadGrid>

and the source code is 

Private Sub dgrdResults_DetailTableDataBind(ByVal source As Object, ByVal e As Telerik.WebControls.GridDetailTableDataBindEventArgs) Handles dgrdResults.DetailTableDataBind
Dim db As Database

 

 

Dim dataset As DataSet = Nothing

 

 

Dim dbCommandWrapper As DbCommand = Nothing

 

 

Try

 

db = DatabaseFactory.CreateDatabase()

dbCommandWrapper = db.GetStoredProcCommand(

"spListGetByRecipient")

 

db.AddInParameter(dbCommandWrapper,

"@recipientId", DbType.Int32, 100125)

 

dataset = db.ExecuteDataSet(dbCommandWrapper)

e.DetailTableView.DataSource = dataset

dataset.Dispose()

dbCommandWrapper.Dispose()

 

Catch ex As Exception

 

 

Throw ex

 

 

Finally

 

 

If (Not dbCommandWrapper Is Nothing) Then

 

dbCommandWrapper.Dispose()

 

End If

 

 

If (Not dataset Is Nothing) Then

 

dataset.Dispose()

 

End If

 

 

End Try

 

 

End Sub

And in this code e.DetailTableView.DataSource = dataset  I get table with values, but in browser "No record bind" message shown .
Does I miss something or forget anything in code?
 Please help me

 

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Jan 2012, 10:59 AM
Hello Prajeesh,

Please remove below code from your code/.
<ParentTableRelation >
 
<radG:GridRelationFields DetailKeyField="ID" MasterKeyField ="RecipientId" />
 
</ParentTableRelation>


Please modify/Add below code
protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
   {
       int recipientId = Convert.ToInt32((e.DetailTableView.ParentItem as GridDataItem).GetDataKeyValue("recipientId"));
 
// now pass this ID into srored procedure and get data and assign it
        
       e.DetailTableView.DataSource = data;
        
   }



Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Prajeesh
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or