473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Hide/Show EditCommandColumn In DataGrid

RN1
A Form has a few fields along with a Submit button & a DataGrid. The
fields & the Submit Button are encapsulated in a Panel named
pnlDataEntry & the DataGrid is encapsulated in a Panel named
pnlShowData. There is also a Session variable which comes from the
login page. If the user logs in as admin, then the session variable is
1 else 0. This is the code:

---------------------------------
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
If Not (Page.IsPostBack) Then
Dim sessAdmin As Integer

sessAdmin = Session("Admin")

If (sessAdmin = 0) Then
pnlDataEntry.Visible = True
pnlShowData.Visible = False
Else
pnlShowData.Visible = True
Call LoadData()
End If
Else
pnlDataEntry.Visible = False
pnlShowData.Visible = True
Call LoadData()
End If
End Sub

Sub Submit(ByVal obj As Object, ByVal ea As EventArgs)
Dim dtEnd As DateTime
Dim dtStart As DateTime

pnlDataEntry.Visible = False
pnlShowData.Visible = True

dtStart = ............
dtEnd = .............

If (CDate(dtEnd) < CDate(dtStart)) Then
Response.Write("END TIME CANNOT PRECEDE START TIME!")
Else
Call InsertData(dtStart, dtEnd)
Call LoadData()
End If
End Sub

Sub InsertData(ByVal StartDate As DateTime, ByVal EndDate As DateTime)
'inserting data in the database
End Sub

Sub LoadData()
'binding data from the database to the DataGrid
End Sub

<form runat="server">
<asp:Panel ID="pnlDataEntry" runat="server">
......................
......................
</asp:Panel>

<asp:Panel ID="pnlShowData" runat="server">
<asp:DataGrid ID="dgETS"..............runat="server">
<Columns>
<asp:BoundColumn............../>
<asp:BoundColumn............../>
<asp:BoundColumn............../>
<asp:BoundColumn............../>
<asp:EditCommandColumn CancelText="CANCEL" EditText="EDIT"
HeaderText="EDIT" UpdateText="UPDATE"/>
</Columns>
</asp:DataGrid>
</asp:Panel>
</form>
---------------------------------

What I want is if the user logs in as admin i.e. sessAdmin=1, then
only should the DataGrid display the EditCommandColumn in the DataGrid
else the EditCommandColumn should remain hidden. Also the last 2
BoundColumns should be visible only if the user logs in as admin else
they should not be visible.

How do I do this?
Oct 6 '08 #1
0 1260

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
1
by: George Durzi | last post by:
I have an editcommandcolumn in my datagrid, as follows. <asp:editcommandcolumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"> I'd like to set the...
3
by: Jaime | last post by:
Hi all, I have a datagrid with 2 databound columns and one EditCommandColumn, now when I press the edit link, the correct OnEditCommand event is generated and my user defined function is called...
0
by: scott_nilspam | last post by:
I need to know how to show/hide an EditCommandColumn at runtime. I know that I can use Datagrid.Columns(x).Visible, but how do I determine the x. I looked through the Help files and on Google...
0
by: slemen | last post by:
Hi, The DataGrid aps:EditCommandColumn when used with column templates created programmatically does not trigger the _Edit subroutine in code. The ASP:Datagrid definition is below (1), the...
0
by: slemen | last post by:
Hi, The asp:EditCommandColumn template does not fire the _edit sutboutine when the edit command column buttons are clicked. I get a Page Cannot Be Displayed page error instead. My (ASP 1.1)...
0
by: Ian | last post by:
Hi I have used the following code to essentially late bind an EditCommandColumn to my datagrid in ASP.NET. EditCommandColumn ec = new EditCommandColumn(); ec.ButtonType =...
0
by: rcoco | last post by:
Hi, I have a datagrid that is ment to insert data. But when I run the form only the header appears. I would like some advise from you all and solve this problem I'm using visual studio 2003. My...
0
by: RN1 | last post by:
I have a DataGrid with an EditCommandColumn. In the EditCommand sub of the DataGrid, there is an If condition. This If condition is True for some rows in the DataGrid whereas it is False for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.