Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 1959 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > Getting a Gridview selected cell value directly without loop the gridview ...
Manu

Getting a Gridview selected cell value directly without loop the gridview

Replies: 1 | Posted by: Manu on 4/14/2009 | Category: C# Forums | Views: 16055 | Status: [Member]  


Visual Stoduio 2008, ASP.net and C# coding ( Web forms )
I have a GridView and a button in a Web based form. May some one please help me with the following.
When using GridView, how do we get the value directly of a selected cell into a variable or use the value of the selected cell to pass it to a a variable without looping through the grid rows and columns.
All i am asking please, is the code which accessed the Gridview cell value without having to loop through the whole gridview rows and columns. I would like to directly access the selected value without to much code. Just one or two lines of code please.


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Vuyiswamb
Vuyiswamb  
Posted on: 4/14/2009 1:48:26 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator]

Good Morning Manu

it not a Good idea to get the value without Looping, What if a user did a multiselect on the Grid. You have to loop on the Gridview and get the select value of the Cells, i have an example that i used in a Ultragridweb



foreach (UltraGridCell cell in ultraGridCycles.DisplayLayout.SelectedCells)
{

if (cell.Value != null && cell.Value.ToString() != "")
{
cell.Style.ForeColor = System.Drawing.Color.Red;

array.Add(cell.Value);

Session["Cycles"] = array;
}
}


Basucally what i did here i have added the select cells values to a Arraylist and and put them in a Session, you can choose to put the in a session and pass them to a parameterised Method that will call your sp in your DAL

Thank you for Posting in DOTNETFUNDA

We are looking forward for your Reply

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Manu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 10:21:19 PM