Appear in Online Interview to test your skills and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Submit content and win cash & prizes monthly.
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Forums Author
Thu, 24-Apr-2014 Authors
Bageshkumarbagi
10
Chaithragm
10
All Time Authors
Jayakumars
3930
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)

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 : 17475 | 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.



Reply | Reply with Attachment

=> Scroll below for responses


Comments or Responses

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.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.

Found interesting? Add this to: