Advertisements
RSS

Tag Archives: GridView

Using ASP.NET Mobile Forms

I wanted to use the normal ASP.NET Forms stuff in a mobile form.

  • Right click on the web site project and select Add new Item

1

  • Select Mobile Web Form. enter a name for the form and click on Add button

2

  • To use a style sheet & a JavaScript file, I added a DeviceSpecific with SupportJavaScript Filter. this is how the HTML code looks like

3 

  • Now I wanted to created some ASP controls. so I added another DeviceSpecific with isHTML32 Filter. this is how the HTML code looks like

4

 

  • One last thing, in order to make those DeviceSpecific Filters to work you need to add the required keys in the web.config file. this is how this would look like

untitled

Advertisements
 
2 Comments

Posted by on February 5, 2010 in Programming

 

Tags: , , , , , , , , , , , , , , ,

GridView: Wrong Fields Order

 

I was working on a GridView that is binding to a custom class collection to display its properties. the fields in the GridView were ordered depending on the order of the properties in the Class. everything was working fine. until I moved the code to a different development environment.

In the new development environment the order of the GridView fields was not as expected. after spending a lot of time trying to fix that. I installed the .NET 2.0 service pack 2 and that solved the problem!!!!

You can download the .NET 2.0 SP2 from here

http://www.microsoft.com/downloads/details.aspx?familyid=5B2C0358-915B-4EB5-9B1D-10E506DA9D0F&displaylang=en

 
Leave a comment

Posted by on January 27, 2010 in Programming

 

Tags: , , , , , , ,

Using the wheel mouse button with AjaxControlToolkit slider

 I wanted to use the wheel mouse button to slide the slider up or down to use it in a Mapping application for Zoom In/Out, I used a java script function to detect the wheel mouse on the Map, I wanted the Zoom function to start when the user release the wheel mouse so I added a timer to detect that the user stopped using the wheel button 

 

   var hTimer = null;

 

   function wheelZoom(e)

    {

        try

        {

            e = e ? e : window.event;

            var raw = e.detail ? e.detail : e.wheelDelta;

            var normal = e.detail ? e.detail * -1 : e.wheelDelta / 40;

            if (normal > 0)

            {

                var slider = $find(“Slider2”);

                if (slider != null)

                {

                    slider.set_Value(slider.get_Value()-1);

                }

                else

                {

                }

            }

            else if(normal < 0)

            {

                var slider = $find(“Slider2”);

                if (slider != null)

                {

                    slider.set_Value(slider.get_Value()+1);

                }

                else

                {

                }

            }

            if (hTimer != null)

            {

                window.clearTimeout(hTimer)

            }

            else   

            {

           

            }

            hTimer = window.setTimeout(doZoomWheel, 500)

            cancelEvent(e);

        }

        catch(err)

          {

            alert(err.message)

          }

          finally

          {

                  

          }

    }

 

In the above code the slider will response to the wheel mouse but the Zoom function will be called only when the user stop using the wheel button

 

 

function doZoomWheel()

    {

        if (hTimer)

        {

            hTimer = null;

            Zoom();

        }

    }

 

 

 

 
Leave a comment

Posted by on June 10, 2008 in General, Photography

 

Tags: , , , , , , , , , , ,

Dynamically creating a GridView inside AjaxControlToolkit Tabs

I wanted to search through multiple tables in database and display the results in GridViews inside Ajax Tabs, each tab will represent the results of a single table

 

First I need to a add an AjaxControlToolkit Tab Container

 

<cc2:TabContainer  AutoPostBack=”false”  ID=”TabContainer1″ runat=”server” Width=”100%”></cc2:TabContainer>

 

In my Code I will create a function to create the result tab, the input of this function is a DataSet of the search results through a single table and the Table name

 

    Private Sub fillDGResults(ByVal ds As DataSet, ByVal sTableName As String )

         Dim tab As AjaxControlToolkit.TabPanel = New AjaxControlToolkit.TabPanel()

         tab.ID = “tab_” + sTableName  

         tab.Style.Item(“Width”) = “100%”

         TabContainer1.Tabs.Add(tab)

         Dim UpPanel As UpdatePanel = New UpdatePanel()

         Dim printButton As ImageButton = New ImageButton()

         printButton.ImageUrl = “images/print1_norm.PNG”

         UpPanel.UpdateMode = UpdatePanelUpdateMode.Conditional

 

         Dim gv As GridView = New GridView

         gv = CreateGridView()

         gv.ID = sTableName + ds.Tables(0).Rows.Count.ToString()

         printButton.Attributes(“onClick”) = “javascript:CallPrint(‘” & gv.ID & “‘,'” & sTableName & “‘);”

         UpPanel.ID = “up_” + sTableName

         tab.Controls.Add(UpPanel)

         UpPanel.ContentTemplateContainer.Controls.Add(printButton)

         UpPanel.ContentTemplateContainer.Controls.Add(gv)

         gv.Style.Item(“Width”) = “100%”

         gv.DataSource = ds

         gv.PageIndex = 0

         gv.DataBind()

         gv.PageIndex = 0

         tab.HeaderText = sTableName + ” (“ + ds.Tables(0).Rows.Count.ToString() + “)”

         tab.EnableViewState = True

         TabContainer1.EnableViewState = True

     End Sub

 

 

And this is the function to create the GridView

 

 

   Private Function CreateGridView() As GridView

        Dim gv As GridView = New GridView()

        AddHandler gv.RowDataBound, AddressOf gv_RowDataBound

        AddHandler gv.RowCreated, AddressOf gv_RowCreated

        AddHandler gv.RowEditing, AddressOf gv_RowEditing

        AddHandler gv.SelectedIndexChanged, AddressOf gv_SelectedIndexChanged

        AddHandler gv.RowCommand, AddressOf gv_RowCommand

        AddHandler gv.PageIndexChanging, AddressOf gv_PageIndexChanging

        AddHandler gv.PageIndexChanged, AddressOf gv_PageIndexChanged

 

        gv.PageIndex = 0

        gv.EnableViewState = True

        gv.FooterStyle.CssClass = “SimpleGrayTableFooterStyle”

        gv.RowStyle.CssClass = “ResultsPanel”

        gv.HeaderStyle.CssClass = “ResultsPanelHeader”

        gv.PagerStyle.CssClass = “PagerStyle”

        gv.AllowPaging = True

        gv.PageSize = 15

        gv.PagerSettings.Mode = PagerButtons.NumericFirstLast

        gv.PagerSettings.Position = PagerPosition.TopAndBottom

        gv.PagerSettings.FirstPageText = “<<“

        gv.PagerSettings.LastPageText = “>>”

        gv.PagerSettings.PageButtonCount = 5

 

        Dim aspCF As CommandField = New CommandField()

        aspCF.ShowSelectButton = True

        aspCF.ButtonType = ButtonType.Link

        aspCF.SelectText = “<img align=top BorderColor=transparent border=0 alt=’Show in Map’ src=’images/map20_norm.PNG’ />”

        gv.Columns.Add(aspCF)

        aspCF = New CommandField()

        aspCF.ShowEditButton = True

        aspCF.EditText = “<img align=top BorderColor=transparent border=0 alt=’Show Info’ src=’images/view_norm.PNG’ />”

 

        gv.Columns.Add(aspCF)

        gv.Page = Me.Page

        CreateGridView = gv

 

    End Function

 

 

Finally I would like to thank Siderite for his help

 

 
1 Comment

Posted by on June 4, 2008 in General, Programming

 

Tags: , , , , ,

 
%d bloggers like this: