GridView SelectedRow

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/8/2010 11:48:57 AM
Gravatar
Total Posts 25

GridView SelectedRow

Hi Joe:

I am using the mojoGridView to display some data. The grid is wrapped in <div class="AspNet-GridView">

When someone clicks on a cell I need to cell color to change. I have the following code but it is not working.. Please help. Thanks

private void Gridview_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

             e.Row.Attributes.Add("onmouseover",

             "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#FF9955'");

               e.Row.Attributes.Add("onmouseout",

              "this.style.backgroundColor=this.originalstyle;");
}

}

10/8/2010 8:24:40 PM
Gravatar
Total Posts 111
Matt Millican InternetMill

Re: GridView SelectedRow

Are you wanting to change colors on mouse OVER or CLICK?  Two completely different scenarios.

10/11/2010 9:19:27 AM
Gravatar
Total Posts 25

Re: GridView SelectedRow

Hi Joe:

I just need to change the color of the selectedrow.. not on mouseover.

Uday

10/11/2010 1:24:36 PM
Gravatar
Total Posts 111
Matt Millican InternetMill

Re: GridView SelectedRow

Do something like this: 

protected void gvResellers_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
            gvResellers.Rows[e.NewSelectedIndex].BackColor = System.Drawing.Color.Gray;
}  

10/11/2010 1:36:17 PM
Gravatar
Total Posts 25

Re: GridView SelectedRow

Thanks Joe:

I already tried that.. but do not see any change in color when the selected index is fired.. I am using the Yahoo GridView css could that be the issue?

Uday

10/11/2010 1:50:11 PM
Gravatar
Total Posts 18439

Re: GridView SelectedRow

Hi,

What you need to understand is that mojoGridView uses the CSS adapater to make cleaner markup than a normal <asp:GridView

You probably can style a selected row using:

.AspNet-GridView-Selected { }

It will not use inline styles, if you prefer the original GridView rendering behavior just use <asp:GridView instead of mojoGridView

Hope it helps,

Joe

10/11/2010 2:18:49 PM
Gravatar
Total Posts 25

Re: GridView SelectedRow

Thanks Joe:

That's exactly what I was looking for.

 

Uday

2/10/2012 2:52:50 AM
Gravatar
Total Posts 42

Re: GridView SelectedRow

 

Does anyone know how to make a row within a grid CLICKable , without using a select button  and create a click event ?

will not go into too much detail, but i have tried heaps of different methods  and final got one to work outside the MP environment

now i'm trying to move it into MP  with out much luck

basically i have developed my own control based upon the standard grid ...  and i'm able to trap a row click event ...

the problem with importing the control into MP, is the MP dev evnrionment does no register the new control.

ie

%@ControlLanguage="C#"AutoEventWireup="true"CodeFile="WebUserControl.ascx.cs"Inherits="WebUserControl"%

<%@RegisterNamespace="CustomGridView"TagPrefix="sc"%>

when i try to include the control within the design, i get an error in the desgn " Element ClickableView is not know element ....."

<sc:ClickableGridView ID="GridView2"runat="Server"HoverRowCssClass="hover"OnRowClicked="GridView2_RowClicked">

</sc:ClickableGridView >

Basically SC: ClickableGridview is not defined.

The class is defined within the project/solution , there have been no changes to the web.config file

have is missed something ?

note: i have googled  without much luck

thanks

Lee

 

 

2/10/2012 7:10:44 AM
Gravatar
Total Posts 18439

Re: GridView SelectedRow

You have not registered your control correctly.

<%@Register Namespace="CustomGridView" TagPrefix="sc"%> is not sufficient

you need 

<%@Register Namespace="CustomGridView" TagPrefix="sc" Assembly="your-control-dll-name-without-the-extension" %>

and the dll for your control must be in the /bin folder

and that assumes your ClickableGridView control is in the Namespace "CustomGridView"

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.