IT Community - Software Programming, Web Development and Technical Support

ASP.NET Data Controls

This is a discussion on ASP.NET Data Controls within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi H2o, Thanks for your reply. I have written follwoing code into <EditItemTemplate> of GridView: <EditItemTemplate> &...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #101 (permalink)  
Old 09-10-2007, 03:19 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi H2o,

Thanks for your reply.

I have written follwoing code into <EditItemTemplate> of GridView:

<EditItemTemplate>
<input id="EndDateTextBox" type="text" size="15" value='<%# DataBinder.Eval (Container.DataItem ,"Enddate") %>' />
<a href="javascript:calendar_window =window.open('DatePicker.aspx?formname=form1.EndDa teTextBox' ,'calendar_window','width=250,height=250'); calendar_window.focus()">click</a><br />
</EditItemTemplate>

As you suggested I have changes it as following:

<EditItemTemplate>
<input id="EndDateTextBox" type="text" size="15" value='<%# DataBinder.Eval (Container.DataItem ,"Enddate") %>' /><a href="javascript:calendar_window=window.open('Date Picker.aspx?startDateID='" + startDateTextBox.ClientID + "','calendar_window','width=250,height=250');calen dar_window.focus()">click</a><br />
</EditItemTemplate>
I am getting following error:
1. Attribute 'StartDateTextBox.ClientID' is not a valid attribute of element 'a'.
And when run the application, I cant open "'DatePicker.aspx" page.

Thank you
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #102 (permalink)  
Old 09-11-2007, 02:28 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi,

can you please explain me some doubts are there....

In your master page do you have a form tag?
when you generate the html, what is the id for the form tag?
and what is the id's for your textbox start and end?
with your oiriginal code... not what you modified.... so put back in

calendar_window=window.open('DatePicker.aspx?formn ame=form1.txtStartDate','calendar_window','width=2 50,height=250');calendar_window.focus()

and tell me the output.my guess is that your form is being called something other than from one...which means we have to change that part of the target ( easy, no worries... )or the text boxes are getting client id's different.in either case, we will createe a small javascript, and we will teach you how to inject javascript into the page with asp to take into acount the naming conventions.so we will do something like

<script>
function openpopup()
{
calendar_window=window.open('DatePicker.aspx?formn ame=<%=Page.Form.ClientID%>.<%=txtStartDate.Client ID%>','calendar_window','width=250,height=250');ca lendar_window.focus()
}
</script>
<EditItemTemplate>
<input id="txtEndDate" type="text" size="15" value='<%# DataBinder.Eval (Container.DataItem ,"Enddate") %>' /><a href="javascriptpenpopup()">Pick</a><br />
</EditItemTemplate>

or

calendar_window=window.open('DatePicker.aspx?formn ame=<%=txtStartDate.ClientID%>").','calendar_windo w','width=250,height=250');calendar_window.focus()

and then in the calender js have it directly with your startDate text box, worry about the form and it would be one less poperty call.
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #103 (permalink)  
Old 09-11-2007, 03:35 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi,

I have tried the solution given by you but getting error.. The name 'StartDateTextBox' does not exist in the current context.
I have page as following:
<%
@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CouponMaintenance.aspx.cs" Inherits="CouponMaintenance" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script language="javascript" type="text/javascript">
function openpopup()
{
calendar_window=window.open(
'DatePicker.aspx?formname=<%=Page.Form.ClientID%>. <%=StartDateTextBox.ClientID%>','calendar_window', 'width=250,height=250');calendar_window.focus()
}
</script>
<div>
<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" ShowFooter="True" OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" FooterStyle-BackColor="ActiveBorder">
<Columns>
<asp:TemplateField HeaderText="Start Date" SortExpression="Startdate">
<EditItemTemplate>
<input id="txtStartDate" type="text" size="15" value='<%# DataBinder.Eval (Container.DataItem ,"Startdate") %>' /><a href="javascriptpenpopup()">Pick</a><br />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblStartDate" runat="server" Text='<%# Bind("Startdate") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:TemplateField>
</
Columns>
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="False" ForeColor="#CCFF99" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<HeaderStyle BackColor="#003399" Font-Bold="False" ForeColor="#CCCCFF" />
</asp:GridView>
</td>
</tr>
</table>
</div>
</asp:Content>

I dont have form tage here.How do I solve this problem. Help out.

Thank you
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #104 (permalink)  
Old 09-11-2007, 04:04 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

You still never posted the output html, or what goes to javascript, or the popup for example, seems like you are having client side issues, and you keep giving me the same runtime code back.

I need to see on the client and the javascript. pls post your code....
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #105 (permalink)  
Old 09-11-2007, 11:18 PM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi,

How can I provide output html code instead I am not able to run/debug the application coz I am getting compile error in the script block for txtStartDate, where I have defined it as following:
<script language="javascript" type="text/javascript">
function openpopup()
{
calendar_window=window.open(
'DatePicker.aspx?formname=<%=Page.Form.ClientID%>. <%=txtStartDate.ClientID%>','calendar_window','wid th=250,height=250');calendar_window.focus()
}
</script>
The error is:
'StartDateTextBox' does not exist in the current context

Thank you
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #106 (permalink)  
Old 09-11-2007, 11:52 PM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi venkat,

Ok, let's try this...

remove all the javascript form your aspx page.
Then in the codebehind, in your page load... try something like this, and let's see what happens, i created a test page, and this compiles fine, so you should get something.

if(Page.IsPostBack)
{
string js = string.Empty;
TextBox tb = this.Master.FindControl(this.GridView1.ID).FindCon trol("StartDateTextBox");
if (tb != null)
{
js += "function openpopup(){\n";
js += "DatePicker.aspx?formname=" + tb.ClientID + "','calendar_window','width=250,height=250');calen dar_window.focus();\n";
js += "}\n";
}
if ((js.Length > 0) && (!Page.ClientScript.IsClientScriptBlockRegistered( "popUpJS")))
{
Page.ClientScript.RegisterClientScriptBlock(this.G etType(), "popUpJS", js);
}
}
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #107 (permalink)  
Old 09-13-2007, 12:01 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi,

Thanks for your help.

But still I am getting following error:

Object reference not set to an instance of an object. for this line:
TextBox tb = this.Master.FindControl(this.GridView1.ID).FindCon trol("StartDateTextBox");

Note: one thing I want that StartDateTextBox is in <EditItemTemplate> of the gridview.

Thank you
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #108 (permalink)  
Old 09-13-2007, 12:30 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi guys,

That is why we had the check for null on tb.
what is saying object null... (so that if the box doesn’t exist, no JS is added ).
can you post the exact error message you get, with line numbers and everything...
and then show me that line of the code.
This Gridview or tb.
can you break it down to
Gridview gv = this.Master.FindControl(this.GridView1.ID).;
Textbox tb = gv.FindControl("StartDateTextBox");
that way we can see more exactly which is failing in case the error is on the one big line.
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #109 (permalink)  
Old 09-13-2007, 12:43 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

The final code that I have written is like:
if(Page.IsPostBack)
{
string js = string.Empty;
GridView gv = (GridView)this.Master.FindControl(this.GridView1.I D);
TextBox tb = (TextBox)gv.FindControl("StartDateTextBox");
if (tb != null)
{
js += "function openpopup(){\n";
js += "DatePicker.aspx?formname=" + tb.ClientID + "','calendar_window','width=250,height=250');calen dar_window.focus();\n";
js +=
"}\n";
}
if ((js.Length > 0) && (!Page.ClientScript.IsClientScriptBlockRegistered( "popUpJS")))
{
Page.ClientScript.RegisterClientScriptBlock(
this.GetType(), "popUpJS", js);
}
}

The error message that I gettng while debugging the application is:
{"Object reference not set to an instance of an object."} at line

TextBox tb = (TextBox)gv.FindControl("StartDateTextBox");

The stackTrace is as follows:

" at CouponMaintenance.Page_Load(Object sender, EventArgs e) in e:\\Visual Studio 2005\\Projects\\WebSites\\ABSLLC.Marketing\\ couponMaintenance.aspx.cs:line 25\r\n
at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e)\r\n at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e)\r\n
at System.Web.UI.Control.OnLoad(EventArgs e)\r\n
at System.Web.UI.Control.LoadRecursive()\r\n
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint , Boolean includeStagesAfterAsyncPoint)"
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #110 (permalink)  
Old 09-14-2007, 05:52 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Thumbs up Re: ASP.NET Data Controls

hi,

This is not at server control, this is a HTML control without the runat=server. This is not view in the codebehind (This is a <input /> not a <asp:textbox />)

<EditItemTemplate>
<input id="StartDateTextBox" type="text" size="15" value='<%# DataBinder.Eval (Container.DataItem ,"Startdate") %>' />
<a href="javascriptpenpopup()">Pick</a><br />
</EditItemTemplate>
This generate error here <%=StartDateTextBox.ClientID%>

function openpopup()
{
calendar_window=window.open(
'DatePicker.aspx?formname=<%=Page.Form.ClientID%>. <%=StartDateTextBox.ClientID%>','calendar_window', 'width=250,height=250');calendar_window.focus()
}
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #111 (permalink)  
Old 09-14-2007, 05:54 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Thumbs up Re: ASP.NET Data Controls

hi,

You use the master pages.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CouponMaintenance.aspx.cs" Inherits="CouponMaintenance" Title="Untitled Page" %>

View this examples

ASP.NET QuickStart Tutorials (VB Master and Content Pages)
Click the button View Source
This is the form definition <form id="Form1" runat="server">

Close the window and press the button Run It and view the source code of the generated page.
This is the form definition

<form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm">
The id is different.
Because generate the error
Line: 20
Char:1
Error: 'window.opener.form1.StartDateTextBox' is null or not an object'
code:
url:......

<input id="StartDateTextBox" type="text" size="15" value='<%# DataBinder.Eval(Container.DataItem,"Startdate") %>' />
<a href="javascript:calendar_window=window.open ('DatePicker.aspx?formname=aspnetForm.StartDateTex tBox','calendar_window','width=250,height=250');ca lendar_window.focus()">Pick</a><br />
Or
<input id="StartDateTextBox" type="text" size="15" value='<%# DataBinder.Eval(Container.DataItem,"Startdate") %>' />
<a href="javascript:calendar_window=window.open('Date Picker.aspx?formnam = <%=Page.Form.ClientID%.StartDateTextBox',
'calendar_window','width=250,height=250');calendar _window.focus()">Pick</a><br />
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #112 (permalink)  
Old 09-14-2007, 05:57 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

lnkDateOfPurchase - is a link name having "Date". When u click the link calender will open.

The selected date will be put on to the textbox inside the grid.

Protected Sub lnkDateOfPurchase_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim script As String
Dim mytextbox As TextBox
mytextbox = CType(gvDetails.FooterRow.FindControl("txtDateOfPu rchase"), TextBox)
script = "<script>window.open('MyCalendar.aspx?ToCalDat e=" & mytextbox.Text & "&FormName=" & Page.Form.ID & "&CtrlName=" & mytextbox.ClientID & "','', 'height=200, width=200, top=350, left=350')</script>"

RegisterClientScriptBlock("script", script) CType(gvDetails.FooterRow.FindControl("txtDateOfPu rchase"),
TextBox).Text = txtMyDate.Text

End Sub

Regards
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #113 (permalink)  
Old 09-19-2007, 12:35 PM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi!

I have an asp.net 2.0 gridview on a web page with 10 columns. If the user who accesses the page has admin access, they are allowed to edit eight of the columns. But if they're not admins, they can only edit one of the columns.
I cant' figure out how to set individual columns as readonly. Which command subroutine would you use? The gridview Row Command, RowCreated, Rowdatabound?

In pseudo code, I'd say something like . . .
if useraccess <> "Admin" then
Gridview1.column(2).readonly = true
Gridview1.column(3).readonly = true
Gridview1.column(4).readonly = true
Gridview1.column(6).readonly = true
end if
end sub
For these items, I just want the normal label to display for non-admins, even when the row is in edit mode. I have a couple of columns that are always set to readonly in this grid, and I want these other ones to display the same way (as labels) in edit mode for the non-admins. I don't want the editible text boxes to display.
To clarify that a bit, when you click 'edit columns' on the gridview in the designer, one of the properties you see for each bound field is 'read only' and you can set it to true or false. I have eight of them set for false, which makes them editible. However, for a certain level of user access, I need to set that property to 'true' for seven of the eight columns, and I can't figure out how to do that within code. I think I can do this in the RowCreated event subroutine, but I can't figure out how to get to that column's readonly property. Any guidance or code examples would be greatly appreciated.

Would it be easier to have a second gridview, one for Admins and one for non-Admins and then make the appropriate gridview visible? I could do that, but I was hoping perhaps there might be a way to set the read-only property of these columns based on the user's access level. Which makes more sense? If setting the 'read-only' property of the column makes more sense, could you please provide the correct syntax for accessing that property for a column (with a known column number rather than having to do a 'find control' by name)? I can't figure that one out.

Thanks!
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #114 (permalink)  
Old 09-19-2007, 12:37 PM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Thumbs up Re: ASP.NET Data Controls

Hi venkat...

when you switch to edit mode, you will be re-databinding your underlying data to the edit template. that's a good opportunity to switch some of your columns to a read only mode. you cant be using autogenerated columns if you do this. instead, you'll need to have your columns specified in the markup as bound columns.
This example sets 2 boundfield columns to readonly. you can use whatever logic you need to control which columns to act on and when.
Protected Sub GridView1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBinding

Dim bnd1 As BoundField = DirectCast(Me.GridView1.Columns(0), BoundField)
Dim bnd2 As BoundField = DirectCast(Me.GridView1.Columns(1), BoundField)
bnd1.ReadOnly = True
bnd2.ReadOnly = True

End Sub
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #115 (permalink)  
Old 09-19-2007, 12:38 PM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

I'm sorry! I forgot to mention that these are template fields, not directly bound fields. I tried the code for setting a bound field, and I got the error message, "Unable to ast object of type System.Web.UT.WebControls.TemplateField' to type 'System.Web.UI.WebControls.BoundField.'
Is there a way I can just set this property on the column in the grid view rather than the data field? Please let me know. But if not, please let me know how to work with the Template Field.
I have to admit, I'm baffled. I'm not sure how this is going to work. How do you tell the templated item, "Yes, I know the edit button was clicked setting this row into edit mode, but for this column, don't display the edit item template, but instead, display the item template (the label)"? At least I think that's the question.
I just had an idea! Might I be able , during the page init, to replace the objects in the Edit item templates of these 6 columns with the object (label) in the Item Template? How would I do that. Something like:
Gridview1.row.column(0).templateitem.edititemtempl ate = nothing
Gridview1.row.column(0).templateItem.editItemtempl ate = Gridvew1.row.column(0).templateItem.itemtemplate
I know that's the wrong syntax. I'm not sure how to clear a gridview column etit item template within code and then 'add' to it an object (the label control) from the item template, but that might perhaps work. I just don't have any clue what the correct syntax would be to accomplish that. I'm hoping someone can help.

Thanks!
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #116 (permalink)  
Old 09-20-2007, 08:24 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi Venkat,

Suppose u have a field "UserName" editable for Admin and not editable for the rest

1.Either u can set Enabled= false at OnRowDataBound based on the conditions.
2.Or u can Put two Controls on ItemTemplate of UserName. a label and a textbox

If the user is admin make the textbox template visible with the value.(editable)
Otherwise make the Label visible(non editable)


Regards,
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #117 (permalink)  
Old 09-20-2007, 08:27 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi,

Thank you! However, setting the textbox control enabled property to false in the edit item template is precisely what I DO NOT want to do. It leaves a fakey looking 'textbox' with the data in the textbox grayed out. I want a label to display the text value of the dta clearly. I just don't know the best way to get it there. There's no room for two controls in the edit item template, so I can't just throw in a label and then swap between the textbox and the label using the 'visible' properties. BUT I can replace the textbox control with the label control if someone will tell me how, where in the code, and provide the correct syntax for doing that. I jsut can't figure it out.
Either that or I'll have to build a separate gridview, which I would REALLY RESENT having to do! There should be an easy way of doing this - setting a templated column to readonly so it only ever displays the itemtemplate, even when the row is in edit mode. For example, might there be a way for me to set the 'edit mode' of the individual column to false, on a column by column basis? Please let me know.

Thanks!
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #118 (permalink)  
Old 09-21-2007, 02:45 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi,

Try this then.

The code is to be written on the OnEditing Event of the Gridview1 since u want to modify EditTemplates
foreach(GridViewRow gr in GridView1.Rows)
{
if (((Label)gr.FindControl("lblUserStatus")).Text=="a dmin")
{
((Label)gr.FindControl("lblUserName")).Visible=fal se;
((LinkButton)gr.FindControl("lnkbtnUserName")).Vis ible=true;
}
else
{
//viceversa
}
}
Assuming that u have a filed in gvw to distinguish admin. if no creat one and make its visible="false". it will be simpler

regards
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #119 (permalink)  
Old 09-21-2007, 04:32 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

I'm lost. I don't really follow the code here. Why would I modify the edititemtemplate AFTER someone hits the 'Edit' button. Shouldn't I do that as the gridview is being rendered or something? And I already mentioned that I don't want to put both a label and a textbox in each column's edit item template and then swap between them.
Please let me know if there's a better alternative for me to be able to display the information the way I want and make sure users can't edit data in individual columns when they don't have admin access. I'd REALLY hate to have to create a duplicate gridview just because I'm using Template Items for columns!
I don't use a field in the gridview to distinguish admin vs. non-admin. I have access levels for each user stored in a database by userid. When a user accesses the site initially, I read their access level and store it in a session variable that's used throughout their session to determine access to various parts of the site. It's just controlling access to individual columns that I'm having trouble with.
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #120 (permalink)  
Old 09-24-2007, 02:26 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road