Getting a Gridview selected cell value directly without loop the gridview
Posted by Manu
on 4/14/2009 1:05:25 AM | Views : 16841 | 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
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;
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 MasekoManu, if this helps please login to Mark As Answer. | Alert Moderator