Login  
Search All Forums
Dart Home | PowerWEB LiveControls for ASP.NET | Custom Development Reply | PowerWEB LiveControls for ASP.NET Topics | Forums   
AuthorForum: PowerWEB LiveControls for ASP.NET
Topic: LiveDataGrid Row Selection
Leviathan

From: Kamloops, BC Canada
Posts: 4
Member Since: 10/27/05
posted November 7, 2005 12:38 PM

Are there any examples showing the use of the LiveDataGrid allowing for row selection?

Right now I'm using a LiveButtonColumn, and during the ItemCommand event I grab the text (which is my unique record number) and continue processing.

I would prefer to allow the user to click anywhere on the livedatagrid row instead of only on the hyperlink.

Thanks in advance.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted November 7, 2005 12:40 PM

Have you seen the SlideShow example? It's one of the sample pages that gets installed.

Leviathan

From: Kamloops, BC Canada
Posts: 4
Member Since: 10/27/05
posted November 21, 2005 6:48 PM

I must be missing something in the SlideShow example.

I have a LiveDataGrid, and what I would like to do is allow the user to click on the row (instead of on the LiveButtonColumn). So basically the user can click anywhere on the row and the event will still fire.

Below is a snippet of my LiveDataGrid. Is it possible to allow for a RowClick?

Thanks,

<cc1:LiveDataGrid WaitElementID="spanWaiting" WaitMessage="Loading...." AutoGenerateColumns="false" ID="lgrdUserList" OnItemCommand="lgrdUserList_ItemCommand" runat="server" DataKeyField="UserID" DataSourceID="sourceUserList" Width="350" BorderStyle="None" GridLines="Both" ShowHeader="false">
          <AlternatingItemStyle HorizontalAlign=left BackColor="AliceBlue" Font-Size="8pt" Font-Names="Verdana,Tahoma,Arial" Height=20px />
          <ItemStyle VerticalAlign=top HorizontalAlign=left BackColor=white Font-Size="8pt" Font-Names="Verdana,Tahoma,Arial" Height=20px />
          <SelectedItemStyle BackColor=#F2F2E8 Height=20px Font-Names="Verdana,Tahoma,Arial" Font-Size="8pt" />
          <Columns>
            
            <cc1:LiveButtonColumn ItemStyle-HorizontalAlign="Center" CommandName="Select" ButtonType="LinkButton" DataTextField="UserID" ></cc1:LiveButtonColumn>
            
            <cc1:LiveTemplateColumn>
            
            <ItemTemplate>
            <asp:Table ID="Table1" SkinID="DefaultTable" runat="server" >
              <asp:TableRow>
                <asp:TableCell><b><%# Eval("FirstName")%> <%# Eval("LastName")%></b></asp:TableCell>
                <asp:TableCell HorizontalAlign="Right"><span style="padding-right:8px;"><%# Eval("SecurityRole") %></span></asp:TableCell>
              </asp:TableRow>
              <asp:TableRow>
                <asp:TableCell ColumnSpan="2"><%# Eval("UserName")%></asp:TableCell>
              </asp:TableRow>
              
            </asp:Table>
           </ItemTemplate>
            </cc1:LiveTemplateColumn>
          
          </Columns>
        
        </cc1:LiveDataGrid>
John Talarico



From: Rome, NY USA
Posts: 630
Member Since: 06/01/05
posted November 23, 2005 3:26 PM

Because the LiveDataGrid renders as an HTML Table, as does a Microsoft DataGrid, there is really no control available to handle a click event on a basic table cell. But, tapping into the DataGridItem that represents each row, you can manually add attributes to the cell to handle a click on the client. For example, in the LiveDataGrid's ItemDataBound event which is fired once for each row in the LiveDataGrid when DataBind() is called, you can execute something like this...

for (int i = 0; i < e.Item.Cells.Count; i++)
{
 e.Item.Cells[i].Attributes.Add("onclick","doRowSelect(" + e.Item.ItemIndex + ");");
 e.Item.Cells[i].Style.Add("cursor","hand");
}

Once you do this, you need to use this client-side click to raise a callback to provide the opportunity to set the SelectedIndex. You would create a client-side Javascript function called doRowSelect that takes a single argument (the row index) and uses the LiveCallBack to raise a server side event. In this event, you would set the SelectedIndex of the LiveDataGrid and at that point the behavior would be the same as if you had clicked a standard "Select" button.

Please refer to the product documentation on using the LiveCallback, especially the section under Advanced Topics titled "Creating custom callbacks with LiveCallback".
Reply | PowerWEB LiveControls for ASP.NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX