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

Create linkbuttons in radgrid in alternate coulmns dynamically without Itemtemplate

3 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexis
Top achievements
Rank 1
Alexis asked on 29 Sep 2010, 08:35 AM
Hi Team,
                   I'm using Rad Grid. I want to create Link buttons in RadGrid on alternate columns. I'm not using ItemTemplate. I'm just giving DataSource of RadGrid is DataTable. 

Please help me on this... We need the solution urgently... plz plz help me soon....


My desired output need to be like below. and i need to fire a event hander whenever i click on the link buttons
the I need to Assign the FormatString dynamically to all the Columns like below...

My Requirements:
1) when ever i click the Name column: then the (Header_Click) event handler has to fired. 
2) when ever i click Salary column Link button then (Linkbutton_Click) 
event handler has to fired.
3) I need to assign my custom Format String to all the columns
Example for 3rd Requirement
we are giving Input  like below:
Data                  : 15000
Format String    : $##,##,###.00

we need the Output like below:
$15,000.00

Name

2007

2007

2007

2008

2008

2008

2009

2009

2009

 

Salary

PF

HRA

Salary

PF

HRA

Salary

PF

HRA

 

Alexis

$5000

5%

10

$6000

6%

15

$7000

7%

20

 

Michael

$4000

 

4%

80

$4500

 

4.5%

10

$5500

 

5.5%

15

 

Smith

$3000

 

3%

50

$4000

 

4%

10

$5000

 

5%

15

 

Jessica

$4500

4.5%

10

$5500

5.5%

15

$6500

6.5%

18

 

 

 

 

 








Thanks in advance
Alexis

3 Answers, 1 is accepted

Sort by
0
Alexis
Top achievements
Rank 1
answered on 30 Sep 2010, 10:43 AM
Hi Team,
                If that Format String is not applicable now, then plz help me on that Salary Column Link Buttons. plz i need this solution very urgently...

This two requirements are very urgent.... Please Help me on this....
1) when ever i click the Name column: then the (Header_Click) event handler has to fired. 
2) when ever i click Salary column Link button then (Linkbutton_Click) 
event handler has to fired.

 

Name

2007

2007

2007

2008

2008

2008

2009

2009

2009

 

Salary

PF

HRA

Salary

PF

HRA

Salary

PF

HRA

 

Alexis

$5000

5%

10

$6000

6%

15

$7000

7%

20

 

Michael

$4000

 

4%

80

$4500

 

4.5%

10

$5500

 

5.5%

15

 

Smith

$3000

 

3%

50

$4000

 

4%

10

$5000

 

5%

15

 

Jessica

$4500

4.5%

10

$5500

5.5%

15

$6500

6.5%

18

 

 

 

 

 

 









thanks
Alexis
0
Alexis
Top achievements
Rank 1
answered on 01 Oct 2010, 08:25 AM
By this way i created link buttuons correctly...  

The Header_click event is fire when i click the "NewButton " Link button. but when i click the NButton Series linkbuttons, then its not firing the Det_Click eventhandler.... plz help me on this.... I almost done what i need... just this help i need this...... 

 protected void MainGrid2_ItemCreated(object sender, GridItemEventArgs e)
    {
        try
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                LinkButton linkBtn = (LinkButton)item["NewButton"].Controls[0];
                linkBtn.Click += new EventHandler(Header_Click); // adding click event to LinkButton
                linkBtn.CssClass = "PivotGrid";

                for (int k = 1; k < noofColumns; k++)
                {
                    if (Flag1 == 1)
                    {
                        GridDataItem item1 = (GridDataItem)e.Item;
                        LinkButton lkbtn = (LinkButton)item1["NButton" + k + ""].Controls[0];
                        lkbtn.Click += new EventHandler(Det_Click);// adding click event to LinkButton
                        lkbtn.CssClass = "PivotGrid";
                    }
                    else if (Flag1 == 2)
                    {
                        if (k % 2 == 0)
                        {
                            GridDataItem item2 = (GridDataItem)e.Item;
                            LinkButton lkbtn = (LinkButton)item2["NButton" + k + ""].Controls[0];
                            lkbtn.Click += new EventHandler(Det_Click);// adding click event to LinkButton
                            lkbtn.CssClass = "PivotGrid";
                        }
                        else
                        {

                        }
                    }
                    else if (Flag1 == 3)
                    {
                        if (k == 2 || k % 3 == 2)
                        {
                            GridDataItem item3 = (GridDataItem)e.Item;
                            LinkButton lkbtn = (LinkButton)item3["NButton" + k + ""].Controls[0];
                            lkbtn.Click += new EventHandler(Det_Click);// adding click event to LinkButton
                            lkbtn.CssClass = "PivotGrid";
                        }
                        else
                        {

                        }
                    }

                }
                
            }
            }
we need the solution urgently.... 
Thanks in advance,
Alexis
0
Martin
Telerik team
answered on 04 Oct 2010, 11:22 AM
Hello Alexis,

The issue might be caused by the way you add your link buttons to the items. My suggestion is to use GridTemplateColumn and place the link button in its item template.

I hope this helps.

Regards,
Martin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Alexis
Top achievements
Rank 1
Answers by
Alexis
Top achievements
Rank 1
Martin
Telerik team
Share this question
or