|
Colin's suggestion is a good one. I'd add another - you could put all your controls inside a Panel object, then set the Panel 's Enabled property to true or false. Something like this:
<%@ Page Language="C#" %>
<script runat="server">
void CheckboxChanged(object o, EventArgs e)
{
panel2.Enabled = Checkbox1.Checked;
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
<asp:CheckBox id="Checkbox1" runat="server"
AutoPostBack="true"
Text="Enable the panel"
OnCheckedChanged="CheckboxChanged"
/>
<br /><br />
<asp:Panel id="panel2" runat="server" enabled="false"
Width="400" BackColor="#EFEFEF"
Style="padding: 4px;"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1">
<asp:TextBox runat="server" text="some textbox" />
<asp:DropDownList runat="server" >
<asp:ListItem text="Item1" />
<asp:ListItem text="Item2" />
<asp:ListItem text="Item3" />
</asp:DropDownList>
<asp:Button runat="server" text="some button" /><br />
</asp:Panel>
</form>
</body>
</html>
|
|
|
|
|
Hello,
When I bind a dataset to GridView (.NET 2.0) which has no record, the GridView control is not visible at that time.
Is there any way where in I can persist the visibility of GridView even in case of no data in dataset?
Regards,
Vipul Mehta
Regards,
Vipul Mehta
Software Engineer
Chenoa Information & Software Services Pvt Ltd
|
|
|
|
|
You can use the EmptyDataText property to set a message that will be displayed.
only two letters away from being an asset
|
|
|
|
|
Hi,
I'm having a rather curious problem. I have a GridView (ASP.NET 2.0) that has 3 image fields (commands.) One of those fields deletes the row.
First, the command name was "delete" and so I used the GridView1_RowDeleting event method. I put the code to delete the row from the database there. Then, I changed the command name to "del" and used the GridView1_RowCommand method to catch the command and perform the deletion.
Now, after deleting the row, I would like to reload the updated table from the database and bind it again with the gridview. So I use this:
<br />
GridView1.DataSource = sessionParams.SiteDS.Tables["Users"];<br />
GridView1.DataBind();<br />
sessionParams is a class holding all the Session variables amd SiteDS is the dataset holding the tables of the website.
Now the problem: whenever I click to delete, the row after it also gets deleted, and if it's the last row I get an exception that the index is not valid. That's because the delete command is fired twice, the first time the correct row gets deleted and then for some weird reason, the event is fired again and the row after it gets deleted (since it has the same index now.)
What I noticed afterwards was that this only happens when I use the code that i mentioned above. That is, if I don't do the databind thing, only one row is deleted. However, in this case, the gridview is not updated
So, what is the problem here? Why is the event fired twice?
Thanks.
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Where do you put your sample code to rebind the GridView control? Have you tried it in the PreRender event?
|
|
|
|
|
Hi,
The binding code is in a method that is called from the RowCommand or the RowDeleting click event method. If I put the binding code in the PreRender method, wouldn't it be executed before control passes to the event methods?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
There is something I noticed that is worth mentioning.
This double event firing only occurs when the ButtonField of the GridView is an Image. I have another GridView with ButtonFields shown as links and the event is fired once.
Weird?!?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi,
I am using asp.net 2.0. In this,i am using Cross Page Posting. From the second page, i am trying to reference a control (Label) in the prevoius page using 'PreviousPage' property.
Here, in the first page, that Label control is placed within the "asp:Content" tag. (ie I am using MasterPage's ContentPlaceHolder).
Page.PreviousPage.FindControl("lebelid") method return null.
In case of normal page ( without Masterpage), it works fine. Can anyone help me in this? Thanks in advance.
Regards,
Jay
|
|
|
|
|
Because the Label is placed in the Content control, that also means it is later put in the ContentPlaceHolder control which is a naming container. So you need to get reference to this control fist before accessing the Label control.
|
|
|
|
|
I am tried with refering the NamingContainer before refering the actual control (Label), which is placed within that NamingContainer. It also gives me the output null.
In my previous page, the Label control present within the tag,
<asp:Content ID="Content5" ContentPlaceHolderID="BodyContent" Runat="Server">
</asp:content>
In my second page (using same masterpage) code behind file, i am refering like this,( in Page_Load event)
ContentPlaceHolder myContent = (ContentPlaceHolder)Page.PreviousPage.FindControl("BodyContent");
Still it returns null.
-- modified at 0:05 Saturday 19th August, 2006
-- modified at 0:06 Saturday 19th August, 2006
Regards,
Jay
|
|
|
|
|
hi,
Is it possible to bind the datagrid with the database table rows as columns. In ASP.NET2.0 there is a control called "Details view". i need exactly the same style in ASP.NET1.1.
That is i want the table headers to be in the first column and the row in the next column.
I will the data by a sql statement with select statement.
eg: select ssn,fname,lname where ssn = 1234
|
|
|
|
|
|
I have a vb.net web page with a dropdownlist - the page displays a customer record. The options in the dropdownlist are hard-coded.
I'd like to have the dropdownlist show the value saved in the database when the user pulls up a customer record.
However, when I bind the control to the dataset (default view 0) the dropdownlist displays the value from the database on several lines eg:
o
p
e
n
instead of "open" on one line.
Should I be setting the value of the dropdownlist a different way other than using the databinding ?
Thanks
|
|
|
|
|
Can you show your code here, it would be helpful to reply.
thanks
Naveed Kamboh
|
|
|
|
|
I'm using vb.net. I used the databinding 'wizard' to set the source (eg I click on the control then click on the elipse button in the databinding property)
After selecting the column from the default view, visual studio sets the datasource as - DataBinder.Eval(Dscustomerdetails1, "Tables[customers].DefaultView.[0].type")
|
|
|
|
|
|
Hello Friend,
I am using a treeview and populating it from web.sitemap.
On the basis of text vlaue I want to hide some nodes for the users.
I am not finding how to hide the nodes.
can any one help me please.
thanks
Naveed Kamboh
|
|
|
|
|
Hi,
I'm not sure if this is what you are looking for but here goes.
Tree Looks like this
Tree Node 1
Tree Node 1 a
Tree Node 1 b
Tree Node 1b i
Tree Node 1b ii
Tree Node 1 c
Lets say you want to hide Tree Node 1b ii
TreeView.DataSource = SiteMapDataSource1;
TreeView.DataBind();
TreeView.Nodes[0].ChildNodes[1].ChildNodes.RemoveAt(1); //This hides tree node 1b ii
Hope this helps.
Remember in order to do this you have to programatically bind the TreeView. Note remove the DataSourceID from the IDE first.
Good luck
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
thank you very much dear, it worked.
I am happy.
Naveed Kamboh
|
|
|
|
|
i want a popup menu on right click on the datagrid at client side using javascript. please help me.
sam.
|
|
|
|
|
Create a div element and place the datagrid inside it. Then insert the below mentioned javascript(Popup menu script-Dynamicdrive.com) in the head of the page. Call this javascript from div element "oncontextmenu"
<Head>
<script language="javascript">
//DynamicDrive.com
var defaultMenuWidth="150px" //set default menu width.
var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='<a href="http://dynamicdrive.com">Dynamic Drive</a>'
linkset[0]+='<hr>' //Optional Separator
linkset[0]+='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
linkset[0]+='<a href="http://www.codingforums.com">Coding Forums</a>'
linkset[0]+='<a href="http://www.cssdrive.com">CSS Drive</a>'
linkset[0]+='<a href="http://freewarejava.com">Freewarejava</a>'
linkset[1]='<a href="http://msnbc.com">MSNBC</a>'
linkset[1]+='<a href="http://cnn.com">CNN</a>'
linkset[1]+='<a href="http://news.bbc.co.uk">BBC News</a>'
linkset[1]+='<a href="http://www.washingtonpost.com">Washington Post</a>'
////No need to edit beyond here
var ie5=document.all && !window.opera
var ns6=document.getElementById
if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')
function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}
function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}
function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}
function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}
function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}
function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}
if (ie5||ns6)
document.onclick=hidemenu
</script>
<body>
<div oncontextmenu="showmenu(event,linkset[0]);return false;"><asp:datagrid id="DataGrid1"></asp:datagrid></div>
</body>
</Head>
Raghu
|
|
|
|
|
HI ,,,I ahve some div tags wiht content editable=false in a page...when i delete a div by keeping a cursor in front of div tag i want to know which div tag si going to be deleted...i can use any events inside div tag b'cos all div tags are going to be in a IFrame....
|
|
|
|
|
Please don't cross post.
---
What do you mean? Where is it that you delete the div tag? In the browser? In page source? In the design view?
-- modified at 7:41 Friday 18th August, 2006
---
b { font-weight: normal; }
|
|
|
|
|
Hello! I trying programming in WEB (ASP.NET) and have small (but BIG for me problem.
In my ASp NET page I have button which send to server some ID. The server forms locally file and then must post to client file. How client can download file from server?
Thanks!
(Forgive me for my bad eglish
qqq
|
|
|
|
|