Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
131 views
I have a project in which I have a hierarchical RadGrid contained within a UserControl (usrAccountOverview.ascx).  There is an aspx page that dynamically loads a number of these UserControls based upon which option a user selects in a DropDownList.  The RadGrid binds data just fine at the top of the hierarchy, and if you expand one top-level item in the hierarchy binding works fine within the DetailTable as well.  However, if the page posts back, none of the previously bound data reappears in any expanded DetailTables.

Here is the declarative code for the RadGrid

    <telerik:RadGrid ID="rgMonthly" runat="server" GridLines="None" OnColumnCreated="rgMonthly_ColumnCreated" 
        OnDetailTableDataBind="rgMonthly_DetailTableDataBind" OnItemDataBound="rgMonthly_ItemDataBound" 
        OnNeedDataSource="rgMonthly_NeedDataSource"
        <MasterTableView DataKeyNames="GroupID"
            <DetailTables> 
                <telerik:GridTableView Width="100%" runat="server" DataKeyNames="GroupID"
                    <ParentTableRelation> 
                        <telerik:GridRelationFields DetailKeyField="GroupID" MasterKeyField="GroupID" /> 
                    </ParentTableRelation> 
                </telerik:GridTableView> 
            </DetailTables> 
        </MasterTableView> 
    </telerik:RadGrid> 
 

I am loading the UserControls in the Page_Init method of the aspx page and binding them as in the following:

    protected void Page_Init(object source, System.EventArgs e) 
    { 
        BindSelectedInfo(); 
    } 
 
    protected void BindSelectedInfo() 
    { 
        try 
        { 
            DTSelectedAccts = TAAcctPi.GetData(Int32.Parse(Session["id"].ToString())); 
            for (int i = 0; i < 1; i++) 
            { 
                dsAccountProjections.dtAcctPiRow SelectedAcct = DTSelectedAccts[i]; 
                usrAccountOverview AccountOverview = (usrAccountOverview)LoadControl("~/usrAccountOverview.ascx"); 
                AccountOverview.ID = "usr" + SelectedAcct.SlAcct6Num; 
                AccountOverview.Acct.AcctNum = SelectedAcct.SlAcct6Num; 
                AccountOverview.PullAcctInfo(); 
                pnlHolder.Controls.Add(AccountOverview); 
            } 
        } 
        catch (Exception ex) 
        { 
 
        } 
    } 
 
    protected void rgMonthly_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    { 
        if (!e.IsFromDetailTable) 
        { 
            rgMonthly.DataSource = DMonthlyExpenditures.GetMonthlyExpendituresByGroup(_Acct.AcctNum, firstMonthID, lastMonthID, lastMonthID); 
        } 
    } 
 
    protected void rgMonthly_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) 
    { 
        GridDataItem parentItem = e.DetailTableView.ParentItem; 
        DataTable dtBind = DMonthlyExpenditures.GetMonthlyExpendituresBySubAcct(_Acct.AcctNum, firstMonthID, lastMonthID, lastMonthID, Int32.Parse(parentItem["GroupID"].Text)); 
        if (dtBind.Rows.Count > 0) e.DetailTableView.DataSource = dtBind; 
    } 

Is there some way of getting this to work?

Thanks,

Brian








Brian Furner
Top achievements
Rank 2
 answered on 16 Sep 2009
5 answers
264 views
Hi...

I'm trying to dynamically register some client script in a user control Page_Load method... This user control is triggered by a RadGrid through the EditMode...

AJAX SETTINGS :

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
      <AjaxSettings > 
          <telerik:AjaxSetting AjaxControlID="RadGrid1" > 
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"/>  
               </UpdatedControls> 
              </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 

GRID :

 <telerik:RadGrid ID="RadGrid1" runat="server">  
        <MasterTableView Name="masterView" GridLines="None" EditMode="PopUp" CommandItemDisplay="Top">  
            <CommandItemSettings AddNewRecordText="Add new entry" RefreshText="Refresh" /> 
            <EditFormSettings UserControlName="Control1.ascx" EditFormType="WebUserControl">  
            </EditFormSettings> 
        </MasterTableView> 
    </telerik:RadGrid> 

USER CONTROL UI
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Control1.ascx.vb" Inherits="TestClientScriptRegister.Control1" %> 
<asp:Button ID="Button1" runat="server" Text="Button" /> 

USER CONTROL SERVER SIDE CODE
 Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
    Me.Page.ClientScript.RegisterClientScriptBlock(GetType(String), "Test"Me.GetScript(), True)  
    Me.Button1.Attributes("OnClick") = "Test()" 
  End Sub 
 
  Private Function GetScript() As String 
    Dim sb As New System.Text.StringBuilder()  
 
    sb.Append("function Test() {")  
    sb.Append("alert('what?');")  
    sb.Append("}")  
 
    Return sb.ToString()  
  End Function 

Quite basic stuff...  I know that there's some ways to achieve this without any dynamic script registering but for some reasons, I need to do it that way... 
I tried a bunch of stuff without any success...
 - EnablePageHeadUpdate = "true" in the AjaxManager
 - RadScriptManager.RegisterClientScriptBlock
 - Page.ClientScript.RegisterClientScriptBlock
 - RadAjaxManager.GetCurrent(Page).ResponseScripts

Some remarks...
 - Works well when using a radwindow that calls a page containing the user control.
 - Works well when I remove the ajaxsettings that update the RadGrid in the RadAjaxManager.

Am I missing something?  Maybe I'm not using the grid edit mode the right way...  Is there a way to achieve this?

Thanks for your help : )

Jose
Paul Mc
Top achievements
Rank 1
 answered on 16 Sep 2009
1 answer
85 views
Hi,

I have 2 Bowser Compactablity Issue.
1.Radio Buttons alignment issues in Firefix.
2.CreateTextRange is working IE but Firefox doesn't support... can any one tell me what is the equivalent for the same.


Please Can anyone help out in this.

Thanks,
Jaishri
Schlurk
Top achievements
Rank 2
 answered on 16 Sep 2009
3 answers
196 views
Hi

Is it possible to use OnClientTimeSlotClick and goto the selected date given from eventArgs.get_time()

Thanks
Peter
Telerik team
 answered on 16 Sep 2009
5 answers
1.0K+ views
I am really having trouble adding a template field to a RADGRID in my cs file. Here is what I have: 
public void BindData() 
        { 
            //Default.PK; 
            //int theUser; 
            //string email = Environment.UserName + "recyclingit.com"; 
 
            string sqlConnection = "Data Source=DESQL2008;Initial Catalog=DrawOnTime;User Id=ontimeweb;Password=ontime1234;", query; 
            query="select IncidentId, IncidentNumber, ReportedDate, Users.FirstName + ' ' + Users.LastName as 'IT Employee Assigned', StartDate, CompletionDate, WorkflowSteps.StepName" + 
" from incidents left join Users on Users.UserId=Incidents.AssignedToId left join WorkflowSteps on WorkflowSteps.WorkflowStepId=Incidents.WorkflowStepId where Incidents.ReportedByCustomerContactId = @PK"
            SqlConnection dbconn = new SqlConnection(sqlConnection); 
            dbconn.Open(); 
            SqlCommand myCommand = new SqlCommand(query, dbconn); 
            //myCommand.CommandType = CommandType.Text; 
            //SqlCommand secondCommand = new SqlCommand("select CustomerContactId from CustomerContacts where Email = @email", dbconn); 
            //secondCommand.CommandType = CommandType.Text; 
            SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand); 
            DataSet ds = new DataSet(); 
            myCommand.Parameters.AddWithValue("PK", Default.PK); 
            myAdapter.Fill(ds); 
             
            //sqlquery.Parameters.AddWithValue("email", email); 
 
            myCommand.ExecuteScalar(); 
            RadGrid1.DataSource = ds; 
            RadGrid1.DataBind(); 
            TemplateColumn workFlow = new TemplateColumn(); 
            RadGrid1.Columns.Add(workFlow); 
            dbconn.Close();  
          
             
        } 
Mira
Telerik team
 answered on 16 Sep 2009
1 answer
191 views
Hi ,

When user changes from one page to another page, i want the first row in the new page to be selected.
How to do this?

I tried following.

RadGrid page index changed event  i did the follwoing.

Radgrid1.MasterTableView.Items[0].Selected = true;

But thsi is not working. It is selecting first item in the first page and not the new page.

Can any one please help.

Regards,
Raj

Veli
Telerik team
 answered on 16 Sep 2009
4 answers
250 views
I am using both your RadMenu and Rad Window.  When I open a new RadWindow the RadMenu is on top of the window. 

How do I get the menu to stay behind the window?  Where is the layer setting if that is what it is to set it to be behind the RadWindow?
Fiko
Telerik team
 answered on 16 Sep 2009
1 answer
254 views
I am using a dropdown field in a RadGrid to edit/save a value to a database field. The edit method is via popup. The dropdown list is populated in code behind with the list of the names associated with the values. This is a general concept used in many business models. The data itself is not important to this discussion, only that I am using name/value pairs. The names should be displayed in the dropdown and the values go back and forth to the database. Here is the aspx code setting up the grid column:
            <telerik:GridDropDownColumn DataField="StartRndType" Visible="false" HeaderText="<%$ Resources:TCRS, Start %>" 
                EditFormColumnIndex="0">  
            </telerik:GridDropDownColumn> 
Here's the code behind:
        protected void grdRndPolicy_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                // get the editedItem (row)  
                GridEditableItem eeditedItem = e.Item as GridEditableItem;  
                GridEditManager editMan = editedItem.EditManager;  
 
                // get the record  
                RoundPolicyT dataRecord = e.Item.DataItem as RoundPolicyT;  
                // safety check  
                if (dataRecord == null)  
                    return;  
 
                GridDropDownListColumnEditor editor;  
 
                // All 7 rounding type dropdowns use the same item list -  
                // it does not appear to be necessary to make a new copy for each control  
                IList<ListItem> items = new List<ListItem>();  
                items.Add(new ListItem(Resources.TCRS.Forward, "1"));  
                items.Add(new ListItem(Resources.TCRS.Nearest, "2"));  
                items.Add(new ListItem(Resources.TCRS.Backward, "3"));  
 
                // Start Rnd Type dropdown  
                editor = editMan.GetColumnEditor(_STARTRNDTYPE) as GridDropDownListColumnEditor;  
                editor.DataSource = items;  
                editor.DataBind();  
                editor.SelectedValue = dataRecord.StartRndType.ToString();  
The problem I have is that once the editor.DataSource is set, all the Name values are the same as the Value values, so my SelectedValue is not in the list. I have tried using a NameValueCollection instead of an IList but that had no effect. I also tried using a GridDropDownColumnEditor but that had no effect. Somehow setting the DataSource and doing DataBind causes the dropdown list to be populated with just the Name value. The Name/Value should be different (one the item name, one the item value).
My question is, how do I get the dropdown to populate with the Name/Value pairs?
Veli
Telerik team
 answered on 16 Sep 2009
1 answer
101 views
The images that I upload are more than a megabyte but the image manager always display the file size as 0. Any idea why?
Rumen
Telerik team
 answered on 16 Sep 2009
3 answers
155 views
Hi,

I am trying to create an advanced InlineInsertTemplate. I want the user to be able to select the appointments start and end date/time. Maybe even give the user the opportunity to select a resource for the appointment. If I can get my head arround it!?

I have pasted my InlineInsertTemplate code where I try to do the date and time thing. The problem in this case is that if I choose a start and end time, that differ from each other, the date gets destroyed in month view. The date is totally different from the one I choose.
 
I suspect that it's the way i Bind the controls. But what do I do? And how would I let users choose a resource?

<InlineInsertTemplate> 
      <div id="rsAppointmentEdit" style="background:#fff;">  
        <table cellpadding="0" cellspacing="0" border="0">  
          <tr> 
            <td> 
              Subject  
            </td> 
            <td> 
              <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Subject") %>' TextMode="SingleLine"></asp:TextBox> 
            </td> 
          </tr> 
          <tr> 
            <td> 
              Date  
            </td> 
            <td> 
              <ul class="rsTimePickers">  
                <li class="rsTimePick">  
                  <asp:Label ID="LblFromDate" runat="server" CssClass="timeLabel" Text="from"></asp:Label><%--  
                  --%><telerik:RadDatePicker runat="server" ID="StartDate" CssClass="rsAdvDatePicker" Width="103px" 
                    SharedCalendarID="SharedCalendar" Skin="Vista" Culture="da-DK" MinDate="1900-01-01" SelectedDate='<%# Bind("Start") %>'>  
                  </telerik:RadDatePicker><%--  
                              
                            --%><telerik:RadTimePicker runat="server" ID="StartTime" CssClass="rsAdvTimePicker" 
                Width="85px" Skin="Vista" Culture="da-DK" SelectedDate='<%# Bind("Start") %>'>  
                <TimeView ID="TimeView1" runat="server" Columns="2" ShowHeader="false" StartTime="08:00" 
                  EndTime="18:00" Interval="00:30" /> 
              </telerik:RadTimePicker> 
                </li> 
                <li class="rsTimePick">  
                <asp:Label ID="Label1" runat="server" CssClass="timeLabel" Text="to"></asp:Label><%--  
                  --%><telerik:RadDatePicker runat="server" ID="EndDate" CssClass="rsAdvDatePicker" Width="103px" 
                    SharedCalendarID="SharedCalendar" Skin="Vista" Culture="da-DK" MinDate="1900-01-01" SelectedDate='<%# Bind("End") %>'>  
                  </telerik:RadDatePicker><%--  
                              
                            --%><telerik:RadTimePicker runat="server" ID="EndTime" CssClass="rsAdvTimePicker" 
                Width="85px" Skin="Vista" Culture="da-DK" SelectedDate='<%# Bind("End") %>'>  
                <TimeView ID="TimeView2" runat="server" Columns="2" ShowHeader="false" StartTime="08:00" 
                  EndTime="18:00" Interval="00:30" /> 
              </telerik:RadTimePicker> 
                </li> 
                <li class="rsAllDayWrapper">  
                  <asp:CheckBox runat="server" ID="AllDayEvent" CssClass="rsAdvChkWrap" Checked="false" Text="All day" /> 
                </li> 
              </ul> 
              <telerik:RadCalendar runat="server" ID="SharedCalendar" Skin="Vista" CultureInfo="da-DK" 
                ShowRowHeaders="false" RangeMinDate="1900-01-01" /> 
            </td> 
          </tr> 
          <tr> 
            <td> 
              <asp:LinkButton ID="LnkInsert" runat="server" CommandName="Insert">Save</asp:LinkButton> 
            </td> 
            <td> 
              <asp:LinkButton ID="LnkEdit" runat="server">Edit</asp:LinkButton> 
            </td> 
          </tr> 
        </table> 
      </div> 
      <img id="BobbelPil" src="files/System/Skins/Vista/Scheduler/BobbelPil1.png" /> 
    </InlineInsertTemplate> 
Peter
Telerik team
 answered on 16 Sep 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?