Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
692 views
I have a RadGrid which I am binding it to a DataSet in the C# code. I am also adding a column which is a RadButtonColumn dynamically on the Page Load event. My problem is that I cannot able to set the CommandArgument on that column from the values from one of the Columns in the DataSet.
Also using the GoogleLikeFiltering on it which is working fine.

Any help would be appreciated.

Here is my code:
ASCX:

<

radG:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AllowPaging="True"  

 

AllowSorting="True" AllowFilteringByColumn="True" EnableAJAX="True" EnableAJAXLoadingTemplate="True"  

 

OnNeedDataSource="RadGrid1_NeedDataSource" OnColumnCreating="RadGrid1_ColumnCreating" OnItemCommand="RadGrid1_ItemCommand">  

 

<MasterTableView EditMode="InPlace" DataKeyNames="SubmitId" AllowFilteringByColumn="True" AllowMultiColumnSorting="true" />  

 

<PagerStyle Mode="NextPrevAndNumeric" />  

 

</radG:RadGrid>

C# code:

 

protected

void RadGrid1_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)  

{

ds = GetDataSet();  

 

this.RadGrid1.DataSource = ds;

}

 

 

protected void Page_Load(object sender, System.EventArgs e)

 

try  

 

 

if (!IsPostBack)

{

ds = GetDataSet(); 

 

this.RadGrid1.MasterTableView.Columns.Clear(); 

 

 

//Add Submit Id button to the Grid  

 

 

GridButtonColumn gridButtonColumn = new GridButtonColumn();  

RadGrid1.MasterTableView.Columns.Add(gridButtonColumn);

RadGrid1.MasterTableView.Columns.Add(

 

new GridButtonColumn());

 

gridButtonColumn.UniqueName =

"SubmitId";  

 

 

gridButtonColumn.DataTextField =

"SubmitId";  

 

 

gridButtonColumn.HeaderText =

"SubmitId";  

 

 

gridButtonColumn.DataType =

typeof(int);  

 

 

gridButtonColumn.SortExpression =

"SubmitId";  

 

 

gridButtonColumn.ShowSortIcon =

true;  

 

 

gridButtonColumn.CommandArgument = ds.Tables[0].Columns[

"SubmitId"].ToString();

 

 

 

gridButtonColumn.CommandName =

"processForm";  

 

 

 

 

foreach (DataColumn dataColumn in ds.Tables[0].Columns)

{

 

RadGrid.

MyCustomFilteringColumnCS gridColumn = new RadGrid.MyCustomFilteringColumnCS();  

 

 

 

 

this.RadGrid1.MasterTableView.Columns.Add(gridColumn);

 

gridColumn.DataField = dataColumn.ColumnName;

gridColumn.HeaderText = dataColumn.ColumnName;

}

}

}

 

 

catch (Exception ex)

{

lblMessage.Text =

"PageLoad() " + ex.Message;  

 

 

}

}

 

protected

void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)  

 

 

 

try  

 

 

switch (e.CommandName)

 

case "Filter":

 

foreach (GridColumn column in e.Item.OwnerTableView.Columns)

{

column.CurrentFilterValue =

string.Empty;  

 

 

column.CurrentFilterFunction =

GridKnownFunction.NoFilter;  

 

 

 

break;  

}

 

 

case "processForm":

{

// e.CommandArgument returns "SubmitId"
// But does not get the value for SubmitId from the DataSet

 

 

break;

}

 

 

default:  

 

break;  

}

}

 

 

catch (Exception ex)  

{

lblMessage.Text =

"RadGrid1_ItemCommand() " + ex.Message;  

 

 

}

}

 

 

 

Saqib
Top achievements
Rank 1
 answered on 22 Jun 2009
1 answer
98 views
I am trying to write an application which dynamically adds a tab to a tab strip and a pageview to the multipage and at the same time adds a control to the multi page (my current example uses a button).

I am sucessfully doing all this apart from I have an issue with my code whic is as follows:

when i create the tab and add the button it adds fine but when i press the button the control dissapears from the multipage 

any ideas?

 <asp:Button ID="Button3" runat="server" Text="Button" onclick="Button3_Click" /> 
         
         
         
        <telerik:RadTabStrip ID="ReportTabs" runat="server" SelectedIndex="0" MultiPageID="ReportMultipage">  
            <Tabs> 
                <telerik:RadTab runat="server"  Selected="True" Text="Chart" PageViewID="ReportChartPage">  
                </telerik:RadTab> 
                <telerik:RadTab runat="server" Text="Root RadTab2" PageViewID="RadPageView1">  
                </telerik:RadTab> 
            </Tabs> 
        </telerik:RadTabStrip> 
          
        <telerik:RadMultiPage ID="ReportMultipage" runat="server"  OnPageViewCreated ="RadMultiPage1_PageViewCreated" > 
              
            <telerik:RadPageView ID="ReportChartPage" runat="server" Selected="true" > 
                  
                <asp:Button ID="Button1" runat="server" Text="Button" /> 
                  </telerik:RadPageView> 
                   
                  <telerik:RadPageView ID="RadPageView1" runat="server" > 
                <asp:Button ID="Button2" runat="server" Text="Button2" /> 
                  </telerik:RadPageView> 
                    
        </telerik:RadMultiPage> 


        protected void Button3_Click(object sender, EventArgs e)  
        {  
            Guid gu = new Guid();  
            gu = System.Guid.NewGuid();  
 
            RadPageView page = new RadPageView();  
            page.ID = "Page" + gu.ToString();  
 
 
            Button but = new Button();  
            but.Text = gu.ToString();  
            but.ID = "button" + gu.ToString();  
            page.Controls.Add(but);  
 
            ReportMultipage.PageViews.Add(page);  
 
            RadTab tab = new RadTab();  
            tab.Text = gu.ToString();  
            tab.PageViewID = "Page" + gu.ToString();  
 
 
            ReportTabs.Tabs.Add(tab);  
 
            ReportMultipage.SelectedIndex = 0;  
 
 
 
 
        } 
 
Paul
Telerik team
 answered on 22 Jun 2009
8 answers
215 views
Hi,

I would like to add a custom button to title bar and, associate a RadMenu to this button. I have read some threads about adding custom buttons to title bar, and attaching events but couldn't figured out how to add RadMenu. Is this possible?
Any help will be greatly appreciated.
Georgi Tunev
Telerik team
 answered on 22 Jun 2009
1 answer
86 views
Hi All,

I have two question which may or may not related.

1) how to show loading panel on an image when the page is initially loaded?
2) how to show loading panel on each item( image) in a radcontrol rotator?

TIA

Jerry 
Shinu
Top achievements
Rank 2
 answered on 22 Jun 2009
1 answer
155 views
Hi

I have created a really basic page with a panel that contains some content and a dynamically created link button. When the link button is clicked the panel is updated. The update is supposed to be done by a partial postback using the radajaxmanager but, for reasons I don't understand, every other time the link button is clicked a full postback is performed rather than a partial postback. In other words i get one partial postback then one full postback and so on.

I have reduced the page to its bare bones below. Please can you tell me how I fix this.

<%

@ Register Assembly="AspMapNET" Namespace="AspMap.Web" TagPrefix="cc1" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<!

 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<

 

html xmlns="http://www.w3.org/1999/xhtml" >

 

<

 

head runat="server">

 

 

<title>Untitled Page</title>

 

 

</

 

head>

 

<

 

body>

 

 

<form id="form1" runat="server">

 

 

 

<asp:ScriptManager ID="ScriptManager1" runat="server">

 

 

</asp:ScriptManager>

 

 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

 

 

</telerik:RadAjaxManager>

 

 

&nbsp;

 

 

<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">

 

 

<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

 

 

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

 

 

</asp:Panel>

 

 

 

 

 

</form>

 

</

 

body>

 

</

 

html>


 

Partial

 

Class Default2

 

 

Inherits System.Web.UI.Page

 

 

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

 

Dim l As New LinkButton

 

l.Text =

"link button"

 

 

 

 

 

AddHandler l.Click, AddressOf LinkButton_Click

 

PlaceHolder1.Controls.Add(l)

RadAjaxManager1.AjaxSettings.AddAjaxSetting(l, Panel1)

 

 

End Sub

 

 

 

 

 

Protected Sub LinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

 

Label1.Text = Now()

 

End Sub

 

End

 

Class

 

Nikolay Rusev
Telerik team
 answered on 22 Jun 2009
1 answer
72 views
Hi

I need to exclude the button control from Ajax


If i add the control design time its working fine, but if i add the controls dynamatically its not working(button not exclude from the ajax)

This is my code.

 

RadAjaxPanel panel = new RadAjaxPanel();

 

 

this.Form.Controls.Add(panel);

 

 

Button btn = new Button();

 

btn.Text =

"Click";

 

btn.Click +=

new EventHandler(btn_Click);

 

 

//btn.Attributes.Add("onclick", String.Format("realPostBack(this, ''); return false;"));

 

RadScriptManager1.RegisterPostBackControl(btn);

panel.Controls.Add(btn);


What i needs to do?

Regards
Vairam

Daniel
Telerik team
 answered on 22 Jun 2009
1 answer
178 views
Hi,
I want to build RadMenu from an xml file and a dataset (xsd).
So I load my xml file into dataset.
Xml file:
<?xml version="1.0" encoding="utf-8"?>  
<MenuConfig xmlns="http://tempuri.org/MenuConfig.xsd">  
   <MenuDT> 
    <Id>1</Id>      
    <Text>House</Text> 
    <URL>URL1</URL> 
    <CnfgId>1</CnfgId> 
    <ParentId>null</ParentId> 
  </MenuDT> 
  <MenuDT> 
    <Id>2</Id>      
    <Text>Cars</Text> 
    <URL>URL2</URL> 
    <CnfgId>1</CnfgId> 
    <ParentId>1</ParentId> 
  </MenuDT> 
</MenuConfig> 
and:
MenuConfig menu = new MenuConfig();//dataset  

 

 


menu.ReadXml(MapPath(
"App_Code/MenuConfig.xml"), System.Data.XmlReadMode.IgnoreSchema);  
 
RadMenu1.DataSource = menu.Tables["MenuDT"];  
//Establish hierarchy:  
RadMenu1.DataFieldID = "Id";  
RadMenu1.DataFieldParentID = "ParentId";  
//Set Text, Value, and NavigateUrl:  
RadMenu1.DataTextField = "Text";  
RadMenu1.DataValueField = "Id";  
RadMenu1.DataNavigateUrlField = "URL";  
RadMenu1.DataBind(); 

And I have an error: This constraint cannot be enabled as not all values have corresponding parent values.

I think that ParentId column in xml (set to null) isn't null in c#, it's a normal string.
Is that any solutions to avoid this? At now I change ParentId (in xml) to 0 and set null in c# code (I think that it's not a good idea) :
for (int ii = 0; ii < menu.Tables["MenuDT"].Rows.Count; ii++)  
        {  
            if (Convert.ToInt32((menu.Tables["MenuDT"].Rows[ii]["ParentId"])) == 0)  
            {  
                menu.Tables["MenuDT"].Rows[ii]["ParentId"] = null;  
                menu.Tables["MenuDT"].AcceptChanges();  
            }  
        } 

ParentId column in code of xsd file:
 <xs:element name="ParentId" msprop:Generator_UserColumnName="ParentId" 
msprop:
nullValue="_null" msprop:Generator_ColumnVarNameInTable="columnParentId" 
msprop:
Generator_ColumnPropNameInTable="ParentIdColumn" 
msprop:
Generator_ColumnPropNameInRow="ParentId" type="xs:string" minOccurs="0" /> 
Any ideas how to proper make it?
Veselin Vasilev
Telerik team
 answered on 22 Jun 2009
1 answer
64 views
what i want to do is display the loading.gif image on the controls that i want to update
say i have a label and a button, when i click on a button, it will read database and then put the value on the label to display. but while getting data it display loading1.gif on the label to show that it is working to get the value. i can't seem to get that to work. can you help me? thanks. this is what i have
<telerik:RadScriptManager ID="ScriptManager1" runat="server" /> 
        <telerik:RadAjaxManager ID="RadAjaxManager2" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="Panel1" > 
                    <UpdatedControls > 
                        <telerik:AjaxUpdatedControl ControlID="Panel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting>                
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
         
 
            <asp:Panel ID="Panel1" runat="server" Width="350px" Height="275px"
                <asp:Label ID="Label1" runat="server"></asp:Label> 
                <asp:Button ID="Button1" runat="server" Text="Button" /> 
                 
            </asp:Panel>         
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server"
            <asp:Image id="Image1" runat="server" ImageUrl="loading1.gif"  > 
            </asp:Image> 
        </telerik:RadAjaxLoadingPanel> 

        

     
Princy
Top achievements
Rank 2
 answered on 22 Jun 2009
3 answers
140 views
Hi,

How can i able to enable the disabled date in the Rad Date Picker?

For ex; I have one drop down with some values. on the selection ofeach values i am disabling some date in the rad date picker.
When i change the selection previously disabled date should enable (rigt now its not enabling) and then disable the new set of date for that selection.


Thanks and Regards,
Sushanth Mathew.
Veli
Telerik team
 answered on 22 Jun 2009
3 answers
184 views
I followed your example and added the bottom and left panes with splitter so I could resize my chart but I can't figure out how to add the right pane and splitter.  Could you please help me?

Here is my layout:

 <telerik:RadSplitter ID="trsVertical" runat="server" Orientation="Vertical" >
        <telerik:RadPane ID="LeftPane" runat="server" Width="20px" Scrolling="none" BackColor="#f0f8ff">
        </telerik:RadPane>
        <telerik:RadSplitBar ID="trsVerticalEnd" runat="server" ></telerik:RadSplitBar>
        <telerik:RadPane ID="trpMiddlePane" runat="server" Height="500px" Width="925px" BackColor="#f0f8ff">
            <telerik:RadSplitter ID="trsHorizontal" runat="server" Height="100%" Width="100%" Orientation="Horizontal">
                <telerik:RadPane ID="trpChartPane" runat="server" Height="100%" Width="100%" Scrolling="none" BackColor="#f0f8ff"
                    OnClientResized="ResizeChart">
                    <telerik:RadChart ID="trcRadChart" runat="server">
                        ~~my chart definition goes here~~
                    </telerik:RadChart>
                </telerik:RadPane>
                <telerik:RadSplitBar ID="trsHorizontalEnd" runat="server" ></telerik:RadSplitBar>
                <telerik:RadPane ID="BottomPane" runat="server" Height="20px"  BackColor="#f0f8ff">
                </telerik:RadPane>
            </telerik:RadSplitter>
        </telerik:RadPane>
    </telerik:RadSplitter>



Here is the Ajax code for the resizing:

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">
            function ResizeChart(sender, args)
            {
                var chart = $get("<%= trcRadChart.ClientID %>");
                var chartimg = chart.getElementsByTagName("img")[0];
                chartimg.style.setAttribute("width", sender.get_width() + "px");
                chartimg.style.setAttribute("height", sender.get_height() + "px");
           }
        </script>

</telerik:RadScriptBlock>



Svetlina Anati
Telerik team
 answered on 22 Jun 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?