4 Answers, 1 is accepted
0
Hello Pal,
I suppose you have some global styles for asp:Buttons in your ASP.NET theme. These are applied to the RadGrid buttons as well.
You can either set EnableTheming="false" to the RadGrid control or use SkinIDs for the theme settings, so that they are not applied to buttons unconditionally.
Greetings,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I suppose you have some global styles for asp:Buttons in your ASP.NET theme. These are applied to the RadGrid buttons as well.
You can either set EnableTheming="false" to the RadGrid control or use SkinIDs for the theme settings, so that they are not applied to buttons unconditionally.
Greetings,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tapinder
Top achievements
Rank 1
answered on 15 Oct 2009, 05:27 PM
Hi Dimo,
You are right, I am using global styles for asp:Buttons and these are applied to the RadGrid buttons.
I am using the "ItemDataBound" to set the border of the pager buttons(First, Previous, Next, Last) to zero pixel.
The "ItemDataBound" sets the border for "First" and "Next" buttons to zero pixel but "Previous" and "Last" buttons are still getting the border as per the global styles for asp:Buttons.
I am using the following code to set the border of the RadGrid Pager buttons :-
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
try
{
//create an object of GridPagerItem
GridPagerItem pagerItem = e.Item as GridPagerItem;
//call the function to set the border of buttons to zero pixel
FindButtonAndSetBorder(pagerItem.Controls);
}
catch (Exception ex)
{
//catch the error
}
}
}
------------------------------------------------------------------------------------------------
public static void FindButtonAndSetBorder(System.Web.UI.ControlCollection rootControls)
{
try
{
//check if the rootControls is not null and count is greater than 0
if (rootControls != null && rootControls.Count > 0)
{
//loop through all the each control in rootControls
for (int i = 0; i < rootControls.Count; i++)
{
//if the control type is Button then set its border to 0 pixel
//else call myself again to perform the same action
if (rootControls[i] is Button)
{
Button btnToModify = (Button)rootControls[i];
btnToModify.BorderWidth = Unit.Pixel(0);
break;
}
else
{
FindButtonAndSetBorder(rootControls[i].Controls);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
You are right, I am using global styles for asp:Buttons and these are applied to the RadGrid buttons.
I am using the "ItemDataBound" to set the border of the pager buttons(First, Previous, Next, Last) to zero pixel.
The "ItemDataBound" sets the border for "First" and "Next" buttons to zero pixel but "Previous" and "Last" buttons are still getting the border as per the global styles for asp:Buttons.
I am using the following code to set the border of the RadGrid Pager buttons :-
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
try
{
//create an object of GridPagerItem
GridPagerItem pagerItem = e.Item as GridPagerItem;
//call the function to set the border of buttons to zero pixel
FindButtonAndSetBorder(pagerItem.Controls);
}
catch (Exception ex)
{
//catch the error
}
}
}
------------------------------------------------------------------------------------------------
public static void FindButtonAndSetBorder(System.Web.UI.ControlCollection rootControls)
{
try
{
//check if the rootControls is not null and count is greater than 0
if (rootControls != null && rootControls.Count > 0)
{
//loop through all the each control in rootControls
for (int i = 0; i < rootControls.Count; i++)
{
//if the control type is Button then set its border to 0 pixel
//else call myself again to perform the same action
if (rootControls[i] is Button)
{
Button btnToModify = (Button)rootControls[i];
btnToModify.BorderWidth = Unit.Pixel(0);
break;
}
else
{
FindButtonAndSetBorder(rootControls[i].Controls);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
0
Accepted
Hello Pal,
Your code works as expected on my side. Please review the attached example.
Regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Your code works as expected on my side. Please review the attached example.
Regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tapinder
Top achievements
Rank 1
answered on 20 Oct 2009, 02:29 PM
Hello Dimo,
Thanks for the example. Something is wrong with my code. If i run my code then it still shows border on some pager buttons but if i run your code then it works fine and removes border from all the pager buttons.
Thanks,
Tapinder
Thanks for the example. Something is wrong with my code. If i run my code then it still shows border on some pager buttons but if i run your code then it works fine and removes border from all the pager buttons.
Thanks,
Tapinder
