473,725 Members | 2,053 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 1168
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
5081
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
1889
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
1301
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
3513
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
3832
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
6964
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
4370
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
8888
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
8752
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
9257
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
9174
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
9111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6011
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
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.