?
Solved

Telerik RadGrid control - loop through information and / or identify selected info

Posted on 2011-02-15
3
Medium Priority
?
2,400 Views
Last Modified: 2012-05-11
I need someone familiar with Telerik RadGrid controls to help me.

Or, if you are not familiar, but are willing to help me troubleshoot, that is fine also.

Essentially, I have an event that gets raised when a "Buy" button is pressed.

The event that is raised (and internal C# code) looks like this:

    protected void rgCourseSelect_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "ClearSelection":
                {
                    string isbn = (e.Item.FindControl("lblDataKey") as Label).Text;
                    //remove from cart
                }
                break;
            case "OOS":
                {
                    //Response.Redirect("~/Info/OutOfStock.aspx");
                }
                break;
            case "Used":
                try
                {

                    Telerik.Web.UI.RadGrid myradView = source as Telerik.Web.UI.RadGrid;

                    //RadGrid1.SelectedItems[0].OwnerTableView.DataKeyValues[RadGrid1.SelectedItems[0].ItemIndex]["CustomerID"]

                    e.Item.BorderStyle = BorderStyle.Dashed;
                    e.Item.BorderColor = System.Drawing.Color.LightGoldenrodYellow;
                    e.Item.BorderWidth = 2;

                    string usedprice = (e.Item.FindControl("lblUsedPrice") as Label).Text;

                    string title = (e.Item.FindControl("lblTitle") as Label).Text;
                    string isbn = (e.Item.FindControl("lblDataKey") as Label).Text;
                    string type = "Used";
                    double fusedprice = Convert.ToDouble(usedprice);
                    //Telerik.Web.UI.RadGrid myradView = source as Telerik.Web.UI.RadGrid;
                    string coursedetail = (myradView.Parent.FindControl("lblDescription") as Label).Text;

                    string newused = "Used";
                    int qty = 1;

                    ThemeAwareImageButton tmpUsedButton = e.Item.FindControl("imgAddToCartUsed") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpNewButton = e.Item.FindControl("imgAddToCartNew") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpRentalButton = e.Item.FindControl("imgAddToCartRental") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpEbookButton = e.Item.FindControl("imgAddToCartEbook") as ThemeAwareImageButton;
                    
                    if (tmpNewButton.CommandName != "OOS")
                        tmpNewButton.ImageUrl = "cart-buy.gif";
                    if (tmpRentalButton.CommandName != "OOS")
                        tmpRentalButton.ImageUrl = "cart-buy.gif";
                    if (tmpEbookButton.CommandName != "OOS")
                        tmpEbookButton.ImageUrl = "cart-buy.gif";
                    if (tmpUsedButton.CommandName != "OOS")
                        tmpUsedButton.ImageUrl = "cart-buy.gif";

                    tmpUsedButton.ImageUrl = "bought-check.gif";




                    AddItemsToCart(isbn, title, coursedetail, fusedprice, qty, newused, type);



                }
                catch (Exception)
                {

                }
                break;
            case "New":
                try
                {

                    string newprice = (e.Item.FindControl("lblNewPrice") as Label).Text;
                    string title = (e.Item.FindControl("lblTitle") as Label).Text;
                    string isbn = (e.Item.FindControl("lblDataKey") as Label).Text; string type = "New";
                    double fnewprice = Convert.ToDouble(newprice);
                    Telerik.Web.UI.RadGrid myradView = source as Telerik.Web.UI.RadGrid;
                    string coursedetail = (myradView.Parent.FindControl("lblDescription") as Label).Text;

                    string newused = "New";
                    int qty = 1;

                    ThemeAwareImageButton tmpUsedButton = e.Item.FindControl("imgAddToCartUsed") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpNewButton = e.Item.FindControl("imgAddToCartNew") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpRentalButton = e.Item.FindControl("imgAddToCartRental") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpEbookButton = e.Item.FindControl("imgAddToCartEbook") as ThemeAwareImageButton;



                    if (tmpRentalButton.CommandName != "OOS")
                        tmpRentalButton.ImageUrl = "cart-buy.gif";
                    if (tmpEbookButton.CommandName != "OOS")
                        tmpEbookButton.ImageUrl = "cart-buy.gif";
                    if (tmpUsedButton.CommandName != "OOS")
                        tmpUsedButton.ImageUrl = "cart-buy.gif";


                    tmpNewButton.ImageUrl = "bought-check.gif";




                    AddItemsToCart(isbn, title, coursedetail, fnewprice, qty, newused, type);

                }
                catch (Exception)
                {
                }
                break;
            case "Ebook":
                try
                {


                    string ebookprice = (e.Item.FindControl("lblEbookPrice") as Label).Text;

                    string title = (e.Item.FindControl("lblTitle") as Label).Text;
                    string isbn = (e.Item.FindControl("lblDataKey") as Label).Text;
                    string type = "Ebook";
                    double fusedprice = Convert.ToDouble(ebookprice);
                    Telerik.Web.UI.RadGrid myradView = source as Telerik.Web.UI.RadGrid;
                    string coursedetail = (myradView.Parent.FindControl("lblDescription") as Label).Text;

                    string newused = "Ebook";
                    int qty = 1;

                    ThemeAwareImageButton tmpUsedButton = e.Item.FindControl("imgAddToCartUsed") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpNewButton = e.Item.FindControl("imgAddToCartNew") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpRentalButton = e.Item.FindControl("imgAddToCartRental") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpEbookButton = e.Item.FindControl("imgAddToCartEbook") as ThemeAwareImageButton;


                    if (tmpNewButton.CommandName != "OOS")
                        tmpNewButton.ImageUrl = "cart-buy.gif";
                    if (tmpRentalButton.CommandName != "OOS")
                        tmpRentalButton.ImageUrl = "cart-buy.gif";

                    if (tmpUsedButton.CommandName != "OOS")
                        tmpUsedButton.ImageUrl = "cart-buy.gif";

                    tmpEbookButton.ImageUrl = "bought-check.gif";



                    AddItemsToCart(isbn, title, coursedetail, fusedprice, qty, newused, type);



                }
                catch { }
                break;
            case "Rental":
                try
                {


                    string rentalPrice = (e.Item.FindControl("lblRentalPrice") as Label).Text;

                    string title = (e.Item.FindControl("lblTitle") as Label).Text;
                    string isbn = (e.Item.FindControl("lblDataKey") as Label).Text;
                    string type = "Rental";
                    double fusedprice = Convert.ToDouble(rentalPrice);
                    Telerik.Web.UI.RadGrid myradView = source as Telerik.Web.UI.RadGrid;
                    string coursedetail = (myradView.Parent.FindControl("lblDescription") as Label).Text;

                    string newused = "Rental";
                    int qty = 1;

                    ThemeAwareImageButton tmpUsedButton = e.Item.FindControl("imgAddToCartUsed") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpNewButton = e.Item.FindControl("imgAddToCartNew") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpRentalButton = e.Item.FindControl("imgAddToCartRental") as ThemeAwareImageButton;
                    ThemeAwareImageButton tmpEbookButton = e.Item.FindControl("imgAddToCartEbook") as ThemeAwareImageButton;



                    if (tmpNewButton.CommandName != "OOS")
                        tmpNewButton.ImageUrl = "cart-buy.gif";

                    if (tmpEbookButton.CommandName != "OOS")
                        tmpEbookButton.ImageUrl = "cart-buy.gif";
                    if (tmpUsedButton.CommandName != "OOS")
                        tmpUsedButton.ImageUrl = "cart-buy.gif";

                    tmpRentalButton.ImageUrl = "bought-check.gif";


                    AddItemsToCart(isbn, title, coursedetail, fusedprice, qty, newused, type);



                }
                catch { }
                break;

            default:
                break;
        }

    }

Open in new window



Right now my focus is on the case of "Used".

string usedprice = (e.Item.FindControl("lblUsedPrice") as Label).Text;
string title = (e.Item.FindControl("lblTitle") as Label).Text;
string isbn = (e.Item.FindControl("lblDataKey") as Label).Text;
     
After these lines run, the variables "usedprice", "title" and "isbn" are all empty, although they clearly are there on the screen.


I believe the values are there, I just think that the way I am trying to obtain the values is not working right.


TIA for your help, folks!


Tom    
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 2000 total points
ID: 34904117
Hi, Can you wait for two days, because I have all the video tutorials of the Telerik Rad Controls. I will try to upload on my blog as early as possible. It is very helpful to you for solving this problem.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 34909128
Late yesterday I just barely solved this....so no rush....I think you can just let this go for now.

I will post my solution in a little while.

Essentially the "EnableViewState" needs to be TRUE or the information does not show-up.


0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 34909623
thx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question