Forms Data Controls :: Getting A Value From A Not Visible Field?
Dec 13, 2010
I have a gridview that selects employees. On a button event I want to capture the userid of the selected employee's row. The employee does not need to see their userid so I would prefer that it is not visible. Is there a way to get that cell's value when it is set to visible = false in the columns editor or is there a better way to handle this?
<asp:ButtonField Text="Void" ButtonType="Link" CommandName="Void" /> ' RowCommand Dim f_iIndex As Integer = Convert.ToInt32(e.CommandArgument) Dim f_oSelectedRow As GridViewRow = grdMeterCorrection.Rows(f_iIndex) Dim f_oCertIdCell As TableCell = f_oSelectedRow.Cells(11) Dim f_sCertId As String = f_oCertIdCell.Text.Trim If e.CommandName.ToLower = "void" Then Dim f_bVoidRet As Boolean = VoidCert(f_sCertId) End If
The problem is the CertId field in the GridView has visible set to false. I think this makes the value unaccessable to the RowCommand.
I have a template field in datagrid. The field shows in insert mode. I do not want to show it because it is a thumbnail to an attachment. The regular bound fields have a setting "Insert Visible" which could be set to false - that is supposed to hide them in insert mode. The template field has no such thing. I have even tried to put Insert Visible = False in to the source but to no avail.
My definition of the template field looks like this:
I am using a GridView Control to display multiple fileds with 0's and 1's.
I am using template fields where CheckBoxes are used.
Where exactly and how do I apply the Logic to get a checked CheckBox when field Value=1 and unchecked CheckBox when field Value=2 .Also some times to be able to write a YES where fieldValue=1 or NO where filedValue=0
I have 2 fields in my gridview one called ScriptType the other BagNo, when a user click the edit button, I would like the BagNo filed to be disabled if the ScriptType field is = "TTA" and enabled otherwise. How can I do this?..something along these lines see below..I am using VB..
I have a DetailsView on the page and I have made one of the fields a TemplateField. In the EditItemTemplate and InsertItemTemplate I have a DropdownList that is databound to a table in my Sql Server database. I wanted to add an initial value to the DropdownList namely "- select -" .
I set the AppendDataBoundItems property to true and added the initial value as a ListItem.Markup of the DropdownList
This works fine for new input. The problem is however that the database already has records that were entered through a Windows Application and many of these records has a null value in this field and exceptions are thrown when I tried to open these records and the system tried to set the SelectedValue of the DropdownList.After some more searching I found this help
This now solved the problem of opening a record where the value is null in the database, BUT now the RequiredFieldValidator is not validating anymore to make sure that a databound item is selected for this field and not the initial value "- select -". So basically now it is not checking anymore to see if valid input has been entered for the DropDownList and it accepts "- select -" thus it acts as if the field is not a required field anymore.
In short what is required is that I want to make sure that the user enters a valid selection in the DropDownList, but it must also cater for old records that do not have this field entered yet so that those old records can be opened in the DetailsView .Opening Old records (with null in that field):When these old records are opened in the DetailsView the DropDownlist should show "- select -" when the value in the database is null.
Saving records (old or new records):When saving the record in Insert mode or Update mode the RequiredFieldValidator should show that a valid input is not selected if the DropDownList is still on "- select -".
I have a grid view, and I add new column as a hyper link field, I want the navigationURL for this field to be Pageexample.aspx?ID=other field value like this
I have a database field called ImageLocation, I have the ImageUrl property bound to: Eval("ImageLocation", "{0}")I would like to bind the Visble property to false if the ImageLocation is null data. I can not figure out how to set the control properly, currently the Datalist shows me all the data and when the image location is null it shows me the name of the Hyperlink control which happens to be Hyperlink2.
I have a problem displaying data in a Grid View control when set a row to visible = false when a certain condition is true.
For example, if a DataRowData value has a condition set to true (custom in table) I set the visible property to false, so the data row will not be visible at run time.
The problem is that I'm using paging (10 rows per page) and if 8 of those rows fall into the true condition that won't show the row, that grid view page will only show two rows of data in page 1. The worst scenario is that if I go to page 2 of the grid view and all the rows (10) fall into the true condition, that grid view page will not show any data at all.
How can I show 10 rows of data at all times in a gridview? In other words, I would like to just show the visible rows at all times.
Im into a situation, where, I need to embed linkbutton to gridview to display one field (TITLE) from database. It was done as I've added it in the itemtemplate. Now my situation is bit refined; I should add a text box and another linkbutton which should be disabled on page load and when ever I click that linkbutton which is displaying (TITLE) should make the textbox and another linkbutton visible by displaying corresponding values from the database in the textbox.
I'm trying to loop through a manually created row's controls in a gridview and set the visible property.
I can use findcontrol and it works fine and I don't have to loop. But there are a lot of controls, so I just wanna do it in a loop. But it never finds the control type I'm looking for. Here's my code:
I have a master/detail page using a gridview as the master, and a detailsview as the details. The gridview is set to select a record, and the detailsview picks up the ID and you can either edit that record, or add a new one.The detailsview is set up with various template fields, and if everything on the page is visible, it works OK.However, I wanted to hide the Gridview when the user in working with the detailsview. But if I do that, the detailsview doesn't update the record.
I have a form with a ton of gridview controls on it. All of which are driven by a dropdown list control. When I select a value from the dropdown list control it populates the 5 gridview controls with data from the database.If there are no rows associated with the record from the dropdown list then I am going to set the visible property of all of the gridview cotrols to false.
I know how to set the property I just need to know where I would set it and what I would check.I can put my code in the selectedindexchanged event for the dropdownlist control but how do I check to see if there are no rows associated with that value? Maybe some sort of If gridview1_rowdatabound = 0 then...
Whenever you turn off the visibility of a column in Gridview, on Edit, the value becomes null because its never bound. The only way I know of stopping this behavoir is to put it in the DataKeyName list. Is there any other way to prevent this? I have quite a few columns that will not be displayed in this "release" but I want there for future extensibility. Also, in some cases these values will be used for calculations but the user should not see them. Is there no toggle property for "non-visible" items to remain "unchanged" or something of the sort?
I've created a gridview having an Id column whose visible property is set to false, because I don't want users to see that column. Now when user clicks on the edit button in a particular row I want to fetch the id of the cell in the Id column of that particular row. So, for that purpose I used -
In the above code, Cells 0th index is the column index whose visible property is kept false. Now the problem I face here is that if the columns visible property is true then I can easily fetch the contents of that particular cell with the above code. But, in invisible mode I get only "" value i.e. I don't get the text or the content of that cell. Why does it happen? I don't face this problem with DataGrid Control used with 1.0 and 1.1 version. And how to resolve it or in this case is there another way of fetching the content of the invisible cell?
I have an Outer gridview (called grdvOUTERGRIDVIEW) and an Inner Gridview (called grdvOUTERGRIDVIEW) and I am able to see and use the outer gridview in my codep-behind vb page however when I try to handle an event for the Inner gridview then I get the warning: "handles clause requires a withevents variable defined in the containing type or one of its base types".
After creating the inner gridview I closed the page out and re-opened it however still getting that error and not able to create the grdvINNERGRIDVIEW.RowDataBound event function like I am trying to do.
yearsexp: 4 desc: a description text on the row databound, if there is no value for yearsexp or desc, I would like to make it not visible. The other one needs to still be visible. So far I have