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

RadGrid to RadlistView Databinding

5 Answers 118 Views
ListView
This is a migrated thread and some comments may be shown as answers.
ADAPT
Top achievements
Rank 2
ADAPT asked on 16 Jul 2014, 12:47 PM
Hello community!

I am having issues in getting my RadListView to bind data from a selection in a RadGrid. I have debugged my solution and the get data process is working but the RadListView is not displaying the data. I have examined all relevant demos and searched the web for examples to no avail. Any directional support would be awesome! Here is my code.

My RadGrid
<telerik:RadGrid ID="stGrid" runat="server" GridLines="None" Skin="VLDSkin" EnableEmbeddedSkins="false"
AllowPaging="True" PageSize="15" AllowSorting="True" AutoGenerateColumns="False" OnItemCommand="stGrid_ItemCommand"
ShowFooter="false" ShowStatusBar="false" OnNeedDataSource="stGrid_NeedDataSource" OnSelectedIndexChanged="stGrid_SelectedIndexChanged">
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<MasterTableView CommandItemDisplay="Top" DataKeyNames="StudentID" ClientDataKeyNames="StudentID">
<Columns>
<telerik:GridButtonColumn CommandName="Select" Text="Select" UniqueName="SelectColumn" />
<telerik:GridBoundColumn UniqueName="FirstName" HeaderText="FIRST NAME" DataField="FirstName" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="MiddleInitial" HeaderText="MID NAME" DataField="MiddleInitial" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="LastName" HeaderText="LAST NAME" DataField="LastName" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Address1" HeaderText="ADDRESS" DataField="Address1" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Address2" HeaderText="SUITE/APT" DataField="Address2" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="City" HeaderText="CITY" DataField="City" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="State" HeaderText="STATE" DataField="State" ItemStyle-Wrap="False" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="PostalCode" HeaderText="ZIP" DataField="PostalCode" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="PHONE" ItemStyle-Wrap="False">
<ItemTemplate>
<asp:Literal ID="PhoneLit" runat="server" Text='<%# string.Format("{0:(###) ###-####}", Int64.Parse(Eval("Phone").ToString())) %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn UniqueName="IdentForm" HeaderText="IDENTITY" DataField="IdentForm" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="IDNumber" HeaderText="NUMBER" DataField="IDNumber" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ExpirationDate" HeaderText="EXP DATE" DataField="ExpirationDate" DataFormatString="{0:d}" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="CourseType" HeaderText="COURSE" DataField="CourseType" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Delivery" HeaderText="DELIVERY" DataField="Delivery" ItemStyle-Wrap="False" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="CreditCardType" HeaderText="CARD TYPE" DataField="CreditCardType" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="CreditCardNumber" HeaderText="NUMBER" DataField="CreditCardNumber" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ExpirationMonth" HeaderText="EXP MO" DataField="ExpirationMonth" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ExpirationYear" HeaderText="EXP YR" DataField="ExpirationYear" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="SecurityCode" HeaderText="CVV" DataField="SecurityCode" ItemStyle-Wrap="False" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email" HeaderText="EMAIL" DataField="Email" ItemStyle-Wrap="False">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="True"></Selecting>
</ClientSettings>
</telerik:RadGrid>

My RadListView
<telerik:RadListView ID="statRLV" runat="server" Skin="VLDSkin" EnableEmbeddedSkins="false" DataKeyNames="ID">
<ItemTemplate>
<asp:Table runat="server" Width="100%" CellSpacing="0">
<asp:TableRow>
<asp:TableCell>
<%# Eval("ID") %>
</asp:TableCell>
<asp:TableCell>
<%# Eval("ClientID") %>
</asp:TableCell>
<asp:TableCell>
<%# Eval("LoginStatus") %>
</asp:TableCell>
<asp:TableCell>
<%# Eval("IPAddress") %>
</asp:TableCell>
<asp:TableCell>
<%# Eval("dts") %>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</telerik:RadListView>

CodeBehind
protected void stGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
int _FID = Convert.ToInt32(Session["_FID"]);
StandardClass SC = new StandardClass();
{
if (!SC._IsError)
{
stGrid.DataSource = SC.ReturnStudentClients(_FID);
}
}
}

protected void stGrid_ItemCommand(object source, GridCommandEventArgs e)
{

if (e.CommandName == RadGrid.SelectCommandName)
{
statRLV.SelectedIndexes.Clear();

int _SID = Convert.ToInt32((e.Item as GridDataItem).GetDataKeyValue("StudentID").ToString());
Session["_SID"] = _SID;

StandardClass SC = new StandardClass();
if (!SC._IsError)
{
stRcb.DataSource = SC.ReturnStates();
stRcb.DataTextField = "name";
stRcb.DataValueField = "name";
stRcb.DataBind();

SC.ReturnStudent(_SID);
{
studentIDLbl.Text = Convert.ToString(SC._StudentID);
fnTxBx.Text = SC._FirstName;
miTxBx.Text = SC._MiddleInitial;
lnTxBx.Text = SC._LastName;
ad1TxBx.Text = SC._Address1;
ad2TxBx.Text = SC._Address2;
ciTxBx.Text = SC._City;
coTxBx.Text = SC._County;
stRcb.SelectedValue = SC._State;
pcTxBx.Text = SC._PostalCode;
cuTxBx.Text = SC._Country;
phTxBx.Text = SC._Phone;
foiTxBx.Text = SC._IdentForm;
idnTxBx.Text = SC._IDNumber;
dateTxBx.Text = Convert.ToString(SC._ExpirationDate);
tocTxBx.Text = SC._CourseType;
dmTxBx.Text = SC._Delivery;
toccTxBx.Text = SC._CreditCardType;
ccnTxBx.Text = SC._CreditCardNumber;
exmTxBx.Text = SC._ExpirationMonth;
exyTxBx.Text = SC._ExpirationYear;
scTxBx.Text = SC._SecurityCode;
}

statRLVGetData(_SID);

}

editPnl.Visible = true;
gridPnl.Visible = false;
}
}

protected void statRLVGetData(int _SID)
{
StandardClass SC = new StandardClass();
{
if (!SC._IsError)
{
statRLV.DataSource = SC.ReturnUserLoginStatus(_SID);
}
}
}

protected void stGrid_SelectedIndexChanged(object sender, System.EventArgs e)
{
int _SID = Convert.ToInt32((stGrid.SelectedItems[0] as GridDataItem).GetDataKeyValue("StudentID").ToString());

}



5 Answers, 1 is accepted

Sort by
0
ADAPT
Top achievements
Rank 2
answered on 17 Jul 2014, 03:57 PM
Anyone out there?
0
ADAPT
Top achievements
Rank 2
answered on 18 Jul 2014, 01:54 PM
Is there really no one that can help out here? Telerik? Are you guys monitoring these forums? Desperately need help here.
0
Konstantin Dikov
Telerik team
answered on 21 Jul 2014, 10:43 AM
Hello Tom,

I have examined the provided code snippets, but after creating a sample page, the RadListView is binding as expected. 

For your convenience I am attaching the sample page that I have tested on my end. Please have a look at the attached files and see what differs in your scenario.

if you continue to experience problems with this, please open a regular support ticket and provide a sample, runnable project replicating the issue, so we could test it locally and isolate the root of the problem.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Asutosh
Top achievements
Rank 1
answered on 25 Jul 2014, 07:40 AM
hi
i am using radgridview in radwindow
its works fine but problem is that first time it's width is small and after closing if i reopen radwindow
grid width get 100% 
 i want to make grid width 100% first time 
how to do that ?
0
Konstantin Dikov
Telerik team
answered on 29 Jul 2014, 01:37 PM
Hello Asutosh,

I have tested a simple scenario on my end, but I am unable to replicate the issue that you are describing. Following are the settings that I have tested on my end:
<telerik:RadButton runat="server" ID="RadButton1" Text="Open window"></telerik:RadButton>
 
<telerik:RadWindow runat="server" ID="RadWindow1" Width="700px" Height="500px" OpenerElementID="RadButton1">
    <ContentTemplate>
        <telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" Width="99%"
            AllowPaging="true">
            <MasterTableView Width="99%">
            </MasterTableView>
            <ClientSettings>
                <Scrolling UseStaticHeaders="true" AllowScroll="true" />
            </ClientSettings>
        </telerik:RadGrid>
    </ContentTemplate>
</telerik:RadWindow>

And the code-behind:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(int));
    table.Columns.Add("FirstName", typeof(string));
    table.Columns.Add("LastName", typeof(string));
    table.Columns.Add("Age", typeof(int));
    table.Columns.Add("Date", typeof(DateTime));
    for (int i = 0; i < 55; i++)
    {
        table.Rows.Add(i, "FirstName" + i, "LastName" + i, 20 + i, DateTime.Now.AddDays(i));
    }
 
    (sender as RadGrid).DataSource = table;
}

If you continue to experience this problem, could you please open a regular support ticket and attach a sample, runnable project replicating the exact issue, so we could further investigate it on our end.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ListView
Asked by
ADAPT
Top achievements
Rank 2
Answers by
ADAPT
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Asutosh
Top achievements
Rank 1
Share this question
or