Search
Submit & Win
Submit and win
Cash Prizes !
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Sun, 21-Dec-2014 Authors
All Time Authors
Jayakumars
4210
Karthikanbarasan
3455
Shanky11
3150

Latest members | More ...


(Statistics delayed by 5 minutes)
 Forum Post

Getting a Gridview selected cell value directly without loop the gridview

Manu
Posted by Manu under C# on 4/14/2009 1:05:25 AM | Views : 24907 | Status : [Member] | Replies : 1


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.



Posted by: Vuyiswamb on: 4/14/2009 [Member] [MVP] [Administrator] NotApplicable

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. | Alert Moderator

Login to post response


Share this to:

Bookmark It