The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Accessing cell values in datagrid
Posted: 28 Jul 10 5:18 AM
|
Hi All,
I have the following code executed on the RowCommand event of my datagrid just to see if i can access each of the values in the cells of the row i select (theyll be needed later):
The problem is i dont want all of the columns in the datagrid visible to the user and when i make one of the BoundField columns visible=false the ChosenValue.Text of the related cell comes out as "" (blank). If i then set it to visible=true i get the actual text value out as normal. WHYYYY?????
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = grdZACCOUNTPERSS.Rows[index]; TableCell chosenValue = selectedRow.Cells[0]; TableCell chosenValue2 = selectedRow.Cells[1]; TableCell chosenValue3 = selectedRow.Cells[2]; TableCell chosenValue4 = selectedRow.Cells[3]; TableCell chosenValue5 = selectedRow.Cells[4]; TableCell chosenValue6 = selectedRow.Cells[5]; TableCell chosenValue7 = selectedRow.Cells[6]; TableCell chosenValue8 = selectedRow.Cells[7]; string value = chosenValue.Text; string value2 = chosenValue2.Text; string value3 = chosenValue3.Text; string value4 = chosenValue4.Text; string value5 = chosenValue5.Text; string value6 = chosenValue6.Text; string value7 = chosenValue7.Text; string value8 = chosenValue8.Text; |
|
|
|
Re: Accessing cell values in datagrid
Posted: 28 Jul 10 6:41 AM
|
Im also getting the same issue retrieving the ButtonField cell value i have clicked on regardless of whether its visible or not. |
|
|
|
Re: Accessing cell values in datagrid
Posted: 28 Jul 10 8:23 AM
|
Hi all, ive gotten past this problem now using the DataKeyNames value (the id). My next step is to populate session variables with the values to use when i open the next form but i get the rror: "The GridView 'grdZACCOUNTPERSS' fired event RowEditing which wasn't handled." Im new to the web development side of things but i thought all elements of the link button field click were done in the rowcommand event?
int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = grdZACCOUNTPERSS.Rows[index];
TableCell chosenValue4 = selectedRow.Cells[3]; TableCell chosenValue5 = selectedRow.Cells[4]; TableCell chosenValue6 = selectedRow.Cells[5]; TableCell chosenValue7 = selectedRow.Cells[6];
string value2 = grdZACCOUNTPERSS.DataKeys[0].Value.ToString(); string value4 = chosenValue4.Text; string value5 = chosenValue5.Text; string value6 = chosenValue6.Text; string value7 = chosenValue7.Text; //put details into session variables for populating edit screen Session["ACCOUNTPERSID"] = value2; Session["ZPerson"] = value4; Session["ZFamily"] = value5; Session["ZClass"] = value6; Session["ZStatus"] = value7;
open(); }
protected void open() { if (DialogService != null) { // DialogActionItem DialogService.SetSpecs(300, 300, "EditAccountPersonsResponsible", string.Empty); DialogService.EntityType = typeof(Sage.Entity.Interfaces.IAccount); DialogService.ShowDialog(); } } |
|
|
|
Re: Accessing cell values in datagrid
Posted: 28 Jul 10 8:33 AM
|
Starting to feel a little strange talking to myself here.... 
Ive stopped the error coming up (called my CommandName "Select" instead of "Edit").
But my .ShowDialog line is not opening the form.......
I know it mjst have something to do with autopostback but im still not 100% on my web development behaviours. |
|
|
| |
|