Change gridview skin

I want to change the skin for a gridview using code behind, so that it has a different skin when view on mobile devices. How do I do this?

I have tried this but it doesn’t work:

if (Request.Browser.IsMobileDevice)
{
gvContacts.SkinID = “NPTResults_m”;
}

cheers

So, I take it your are developing for the Windows Phone, as you are using C#? Instead of Java/Android or Objective-C/IPhone?

Unless, I’m not aware of .NET being ported to to the other devices.

And how are you going to view the skin results on an IPhone/Andriod, if C# is not supported?

NightStalker can add more.

spot on - internal system therefore i can guarantee the mobile devices used are windows mobile (aren’t I lucky!) :slight_smile:

Try something like so:


string strUserAgent = Request.UserAgent.ToString().ToLower();
if (strUserAgent != null)
{
if (Request.Browser.IsMobileDevice == true ||
strUserAgent.Contains("windows ce"))

{
//If ya smell what The Rock is cooking!
}
}

Sorry - should have siad i have this bit working - it is the changes the gridview skin that isn’t! :blush:
cheers

Did I go back in time? :lol:

Hmm. I may have to look into WinPhone dev. This is interesting.

Yeah, I’m 26, and STILL a fan of wrasslin! HA! It’s a soap opera for guys…

Hmm. I may have to look into WinPhone dev. This is interesting.

Ditto. Although, I’m not going to jump-in for at least 2 years. Let it mature and saturate the market, to see where Win Phone is going. It is still a baby compared to the 20’something IPhone and Android. Besides that, I don’t plan on jumping on the mobile development bandwagon, as a whole, for awhile. Need to stay focused on WPF and ASP.NET. Knowledge of all…master of none.

I would imagine WPF would cover both. Is WinPhone dev based on Silverlight?

Opps! Brain lapse, yes XAMP is used on both. It’s morning, and I haven’t had my Red Bull, forgive me. :slight_smile:

STOP YOU JIBBERING ABOUT WRESTLING FOOLS OR I’LL GET YOU DOWN AND KICK YO ASS!!! (said in my best deep wrestling shouty voice! :slight_smile: )

I can’t see WinMobile going anywhere anytime soon. Mobile devices are the future and I can’t see MS letting that slip though their fingers!

Anyway - this isn’t fixing my problem - focus people :wink:

Sorry, I have a problem of always getting off topic.

Can you show me the code/markup for: NPTResults_m

in a file called App_Themes\Default\gridview.skin


<asp:GridView runat="server" SkinID="NPTResults_m" AllowPaging="True" AllowSorting="True" PageSize="50" AutoGenerateColumns="False"
	CellPadding="1" CellSpacing="0">	        
    <HeaderStyle CssClass="FieldNameFont" ForeColor="#111111" HorizontalAlign="Left" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#c0c0c0"/>
    <RowStyle CssClass="FieldValueFont" BackColor="#ffffff" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#cacaca" />
    <AlternatingRowStyle CssClass="FieldValueFont" BackColor="#ebebf3" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#cacaca" />
    <PagerSettings Position="TopAndBottom" Mode="NumericFirstLast" />
    <PagerStyle BackColor="#ffffff" HorizontalAlign="Center" CssClass="FieldNameFont" />
    <EmptyDataRowStyle CssClass="FieldValueFont" />
</asp:GridView>

mostley it makes the gridviews more compact for mobile devices but other things may chnage as well.

cheers

Here you go bro. You need Silverlight and XAML to complete your solution.

OR,

http://www.silverlightshow.net/items/Building-a-DataGrid-Control-for-Silverlight-for-Windows-Phone-Part-1.aspx

Cheers buddy. I’ll have a look Monday morning - time to go home now (sorry but that’s time diffs for you! :slight_smile: )

We don’t uses Windows Phone 7 but may do in the future and will give me a starting point anyway :slight_smile:

have a good weekend all!