473,698 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is that possible to add some server script to DataGrid?

hi, all
I just got a question here when I am using the datagrid, my code like this:
<asp:DataGrid id="DataGridBan ner" runat="server" style=....>
.....
<Columns>
<% if(m_adUser.IsW ebMaster()) { %>
<asp:EditComman dColumn Visible='<%# m_adUser.IsWebM aster()%>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
<% } %>
.......
because I only want to show the edit button to web master.
But when I run it, it shows up an error and says, " Code blocks are not
supported in this context", So, can i do this in this page, or I must write
another similar page especially for web master?

Thanks
Nov 19 '05 #1
4 1164
You don't need any ifs. You need just to databinding Visible property, that
is what you are already trying to do.

<Columns>
<asp:EditComman dColumn Visible='<%# IsWebMaster %>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>

IsWebMaster should be a protected or public property of your page class. It
should return true if the user is the web master.

Eliyahu

"Nicky" <Ni***@discussi ons.microsoft.c om> wrote in message
news:F0******** *************** ***********@mic rosoft.com...
hi, all
I just got a question here when I am using the datagrid, my code like this: <asp:DataGrid id="DataGridBan ner" runat="server" style=....>
....
<Columns>
<% if(m_adUser.IsW ebMaster()) { %>
<asp:EditComman dColumn Visible='<%# m_adUser.IsWebM aster()%>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
<% } %>
......
because I only want to show the edit button to web master.
But when I run it, it shows up an error and says, " Code blocks are not
supported in this context", So, can i do this in this page, or I must write another similar page especially for web master?

Thanks

Nov 19 '05 #2
You can also handle the DataGrid's ItemDataBound event. The e.Item passed
as a parameter is the row that was just populated. You can then manipulate
the controls in that row.

-Brock
DevelopMentor
http://staff.develop.com/ballen
You don't need any ifs. You need just to databinding Visible property,
that is what you are already trying to do.

<Columns>
<asp:EditComman dColumn Visible='<%# IsWebMaster %>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
IsWebMaster should be a protected or public property of your page
class. It should return true if the user is the web master.

Eliyahu

"Nicky" <Ni***@discussi ons.microsoft.c om> wrote in message
news:F0******** *************** ***********@mic rosoft.com...
hi, all
I just got a question here when I am using the datagrid, my code like

this:
<asp:DataGrid id="DataGridBan ner" runat="server" style=....>
....
<Columns>
<% if(m_adUser.IsW ebMaster()) { %>
<asp:EditComman dColumn Visible='<%# m_adUser.IsWebM aster()%>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
<% } %>
......
because I only want to show the edit button to web master.
But when I run it, it shows up an error and says, " Code blocks are
not
supported in this context", So, can i do this in this page, or I must

write
another similar page especially for web master?

Thanks


Nov 19 '05 #3
thanks,
I found some fields, it works. But for gernal gound column, like this:
<asp:BoundColum n Visible='<%# IsWebMaster %>' DataField="Crea torID"
HeaderText="Cre atorID"></asp:BoundColumn >
it says:
CS0117: 'System.Web.UI. WebControls.Bou ndColumn' does not contain a
definition for 'DataBinding'
I think this is reasonale. So probably I have to convert it to template and
do it like others columns. Or move all of this logic to the data bind event
routine.

"Eliyahu Goldin" wrote:
You don't need any ifs. You need just to databinding Visible property, that
is what you are already trying to do.

<Columns>
<asp:EditComman dColumn Visible='<%# IsWebMaster %>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>

IsWebMaster should be a protected or public property of your page class. It
should return true if the user is the web master.

Eliyahu

"Nicky" <Ni***@discussi ons.microsoft.c om> wrote in message
news:F0******** *************** ***********@mic rosoft.com...
hi, all
I just got a question here when I am using the datagrid, my code like

this:
<asp:DataGrid id="DataGridBan ner" runat="server" style=....>
....
<Columns>
<% if(m_adUser.IsW ebMaster()) { %>
<asp:EditComman dColumn Visible='<%# m_adUser.IsWebM aster()%>'
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
<% } %>
......
because I only want to show the edit button to web master.
But when I run it, it shows up an error and says, " Code blocks are not
supported in this context", So, can i do this in this page, or I must

write
another similar page especially for web master?

Thanks


Nov 19 '05 #4
So try changing it to Templates
and use DataGrid's ItemDataBound event by manipulating the e.item.
That could save your time.
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5

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

Similar topics

4
5080
by: DM | last post by:
Is there any way, using a server control, to execute a routine (say, add record to database) and then close the browser window. I'm having a difficult time doing this using a master\detail model where dialog apsx page is opened when datagrid item on master page is clicked. Would like to be able to have detail open in the html dialog where user can edit record, then click save button to save changes to database, call opener routine to...
1
1886
by: Ryan McLean | last post by:
Hi everyone! What is happening is the method: sub_btnSubmitClicked is being executed every time any other object with a Handler is executed. I am trying not to use the withevents and handles method of adding handles to objects (I think that is where my problem lies) . . . sorry for the long post here is my codebehind and .aspx code. Thank you for any assistance anyone can offer! Ryan Public Class registration_report
1
1299
by: Martin | last post by:
Hello Group I'm having a bit of trouble figuring this out. I'm grateful for any hints. Let's assume I'm have a webapplication with two .aspx pages, Page A and Page B. Page A consists of a textbox (textbox1) and a HTML Button control. Page B consists of a datagrid control.
2
1104
by: Ing. Rajesh Kumar | last post by:
Hi everybody Is it possible to set the size of text boxes when in edit mode ? Thanks in advance Raja
4
3507
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
9
3830
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
2
6956
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
4369
by: toddw607 | last post by:
Hi Everyone! I have a ASP.NET webform that brings data in from SQL Server 2000 and displays it on a page. I want to update the webpage while in IE using the following code: <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Data.OleDb" %> <html>
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9023
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7721
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.