Hide column data on a row by row basis. How?

I'm sure there is a way to hide/show data of column on a row by row basis.

I've done the following for the admin users, but it displays the whole column.

GridView1.Columns[1].Visible = true;

Let's say I have the following GridView:

Listing Address Sale Price End Date
Tuscany Village SW I-29 169 Hwy   12/31/2007
Plaza Corporate Center 800 W 47th St   12/31/2007
Ward Parkway Plaza 1414 W 85th St   03/12/2007
Pinnacle Corporate Centre II 11460 Tomahawk Creek Pky   03/12/2007
Corporate Medical Plaza 10777 Nall Ave   03/26/2007

How can I show the Edit column based on a UserID I have to work with?

UserID 101 would be associated with Ward Parkway Plaza and Pinnacle Corporate Centre II.

I want that user to be able to see all of the listings but only see the Edit column when there is a match.

 


How about some ringtones, wallpapers and games?
0
eterry28
3/15/2007 5:19:50 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
703 Views

Similar Articles

[PageSpeed] 17

I think I'm close to a solution:

1    protected void TestGridView_RowCreated(object sender, GridViewRowEventArgs e)
2        {
3            if (e.Row.RowType == DataControlRowType.DataRow)
4            {
5                int UserID = (Int32)DataBinder.Eval(e.Row.DataItem, "UserID");
6                Response.Write("USERID: " + UserID + "<br />");
7                e.Row.BackColor = System.Drawing.Color.ForestGreen;
8                if (UserID == Int32.Parse(Session["UserID"].ToString()))
9                {
10                   e.Row.Cells[0].Visible = true;
11               }
12           }
13       }

 Not working, but I think I'm going in the right direction.

Any thoughts?


How about some ringtones, wallpapers and games?
0
eterry28
3/15/2007 8:22:23 PM
imran.nathani:

Check this old post of mine which is similar

http://forums.asp.net/thread/1605746.aspx

Outstanding! Thank you.

here's the code I went with:

1    public bool CheckUserID(string UserID)
2        {
3            if (Session["UserID"] != null)
4            {
5                if ((Session["UserID"].ToString() == UserID) || (Session["Admin"].ToString() == "true"))
6                    return true;
7                else
8                    return false;
9            }
10           return false;
11       }
 
How about some ringtones, wallpapers and games?
0
eterry28
3/15/2007 9:42:13 PM
Reply:

Similar Artilces:

Arranging data on multiple rows into a sigle row (converting rows into columns)
Hello, I have a survey (30 questions) application in a SQL server db. The application uses several relational tables. The results are arranged so that each answer is on a seperate row: user1   answer1user1   answer2user1   answer3user2   answer1user2   answer2user2   answer3 For statistical analysis I need to transfer the results to an Excel spreadsheet (for later use in SPSS). In the spreadsheet I need the results to appear so that each user will be on a single row with all of that user's answers on...

Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once?
 Hi Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once onto the grid? What I mean is some grid that 's as flexible as MS Excel grid for example.  Any suggestions will be very much appreciated.E The Repeater control is a highly customisable data presentation controlRohin.NET developerNever trust a computer you can't throw out a window. - Steve WozniakPlease remember to click on 'Mark as answer', if this post helped you......

Presenting data from column to row
hi, I am encountering one problem regarding data presenting in asp.net data grid. Actaully I want to show column data in one row as record for example as follow column A AAAA BBBB CCC DDD EEE now instead of showing as column i want to show as single row in asp.net datagrid as follow AAAA BBBB CCC DDD EEE please help me asadregards,Asad Mahmood In a Datalist (not sure about datagrid) you can use the propertier RepeatColumns and RepeatDirection to do the aboe. For example, RepeatColumns=5 and RepeatDirection=horizontal ...

Disabling Drop-Down datawindow columns on a row-by-row basis
Here is what I want to accomplish: I have a datawindow that contains two columns - the first is a drop-down datawindow (display column: description, data column: code) and the second is a simple edit. This datawindow will display records currently available for a specific person and will allow inserts to be made and updates to be made on existing rows - for the second column only. This means that I want the drop down datawindows to only function when doing an insert - for those rows that already exist, or those that exist after an update is issued, I want the drop-down capability t...

styling row, hiding buttons
The last row in my 'Edit Categories' gridview is special: it's the 'Miscellaneous' category. I want it to be visually and functionally different: different background color, no 'move up/down' or 'delete' buttons. It has a predictable id (such as -1 or 9999). How can I disable controls in this row's fields? How can I apply a unique CSS treatment to it? (presumably I'm doing an OnRowBound Add-Attribute thing) Can I concatenate two fields into one for this row? (Being a fixed Misc. category, I don't need to give it French te...

ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgid............int imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint incident_id.....int i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

How to go through a datatable row by row and column by column
Hello, I have a dataset with a datatable and I need to insert each row from the datatable on my sql table, anyway there may be errors, so some rows may not be inserted because primary key constraints,  So I need to show the rows that are not inserted in a gridview, the hard thing to do is to go through all the datatable,  is there an wasy way to do it?MCPD ENTERPRISE APPLICATION DEVELOPER Start by looking herehttp://msdn2.microsoft.com/en-us/library/system.data.common.dataadapter.update.aspxPerform an update of your dataset, and if a row fails, you can mark it as invalid.You can ...

Displaying two rows of database column data in one row of datagrid
Hello, I am trying to display two rows of an access column on one row of datagrid. Is that possible? Example of my intended datagrid: courseNo of course1courseNo of course2 courseNo of course3courseNo of course4 here's the HTML view of my aspx file: <Asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP: 40px"    runat="server" AutoGenerateColumns="False" Height="320px" Width="488px">    <Columns>     <asp:TemplateColumn>      &...

Data Controls insert rows into gridview then insert rows from gridview into SQL Table
Hello there, I'm still new at performing miracles with code . Currently I am having trouble with my latest coding adventure I have a web application which records jobs and labour assigned to jobs. The issue in particular I'm having is the way in which labour is to be assigned. I want to use standard controls (Textbox, Dropdownlist) to record the values into a gridview (ie,put multiple rows into the gridview using the controls). Then, when all the inserting is complete, the user clicks a submit button to insert all the rows from the gridview into a database table. The reason for...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Data Set ---- Data Row ( How to retrieve column data in a array )
Question regarding Dataset in ASP.NET ds = DBFunctions.RunSelect("select * from emp where Userid='" & vUserID & "'") If (ds.Tables(0).Rows.Count > 0) Then Dim dr As DataRow = ds.Tables(0).Rows(0)location= dr("location")  -- this statement only gives me the first locaitonMytable userid          location111              AAA111              BBB111         ...

GridView.Rows(Column=ID_PK) to GridView.Rows(Column=DropDownListTeamplteField)
Hi Guys,I wonder how I can assign the PrimaryKey in each GridView Row to the template field in the same row. whereas the template field is filled with a dropdownlist thatshould show the values for retrieved in a different table through the GridView Row primary key (which serves as the SELECT parameter to get these values) The GridView looks like this:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID" DataSourceID="GetC_IDs"> <Columns> <asp:BoundField D...

computing the difference of a column in the current row from the column of the preceding row
Hello, a user asked me if we can solve following problem: we want to compute the difference (delta) of a column in the current row from the column of the preceding row. My first solution signs where: create a computed field (small_function_result) that takes the value from the preceding row: small(value, value, cf_getrow for all); where cf_getrow is a computed field like this: if(getrow()=1,getrow(),getrow()-1) create a computed field (Diff) that computes the difference: value-small_function_result My results should look like this: Row Value cf_getrow small_func...

Web resources about - Hide column data on a row by row basis. How? - asp.net.presentation-controls

Politics, Political News - The Capitol Column
Covering the politics of science, technology, business, entertainment, Capitol Hill, and health.

Trajan's Column - Wikipedia, the free encyclopedia
Trajan's Column ( Italian : Colonna Traiana ) is a Roman triumphal column in Rome , Italy , that commemorates Roman emperor Trajan 's victory ...

Column 8: 'Don't order anything'
A word of warning about the true meaning of Australia Post's 'Hold Mail' service from Brian Jeffrey, of Cook, ACT.

Column 8
&quot;My favourite hotel sign was in India,&quot; writes Michael Robinson, of Cammeray (Column 8, last week). &quot;It read 'The water in this ...

Paris attacks: column in IS magazine warns of 9/11-scale attack to come
Under the byline of a hostage British journalist, Islamic State warns that it may attempt a terrorist attack even bigger than 9/11.

Column 8: More weird 'hotel signage'
&quot;I have more weird 'hotel signage',&quot; offers George Watson, of Grafton (Column 8, Thursday). &quot;The following was posted on the wall ...

The 10 Best Online Columns Of All Time . . .
Former Biglaw partner and inhouse columnist Mark Herrmann identifies the ten best online columns of all time.

Should the Washington Post’s Ties to Reagan Library Be Disclosed in Columns Attacking Bill O’Reilly?
Much has been discussed regarding the recent spat between Washington Post columnist and Fox News contributor George Will and Fox News host and ...

Tim O'Sullivan column: Giving thanks to our father figures on this holiday
Concord Monitor Tim O' Sullivan column: Giving thanks to our father figures on this holiday Concord Monitor That man would be Celtics basketball ...

Mark Bittman's "Fast Company" Column Starts Today
The best-selling author and Emmy award-winning TV personality is writing about his startup experiences exclusively for Fast Company . The influence ...

Resources last updated: 11/30/2015 8:27:15 PM