Solved

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

Posted on 2011-02-15
3
2,387 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 500 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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