|
-
Mar 8th, 2009, 08:28 PM
#1
Thread Starter
Hyperactive Member
[2005] set button display to none
Hi All,
Below is my commandfield embeded with a edit button. How to set the button display into none ?
It work fine in vs 2003 by using style = "display:none"
but it doesn't work in vs 2005.
asp Code:
<asp:CommandField ButtonType="Button" ShowEditButton="false" ShowHeader="True" >
<ItemStyle HorizontalAlign="Center" Width="15px" Wrap="True" />
</asp:commandfield>
Thanks a lot.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Mar 10th, 2009, 02:42 AM
#2
Re: [2005] set button display to none
You can do it from the codebehind by setting the column's Visible property to false.
If you set it in the CSS, then the button is still 'sent' to the client, making the button visible in the HTML source, which is a waste. You should not send it to the client at all, and for that you can set the .Visible property of the column so that it doesn't render.
-
Mar 12th, 2009, 03:15 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] set button display to none
Thanks Mendnak,
I has changed my templates to templateField.
It was solved my problems.
But now I'm facing another problem.
javascript Code:
<script language="javascript" type="text/javascript">
function OnChange_Chk(currCheckBox){
var selectedColor = 'Lavender';
var grid = document.getElementById("<%= grdStatusMaster.ClientID %>");
var Cell;
var pushButtonColumnIndex = 4;
var currRow = currCheckBox.parentElement.parentElement;
var currPushButton = currRow.cells[pushButtonColumnIndex].childNodes[0];
if(currCheckBox.checked){
currRow.oldBackgroundColor = currRow.style.backgroundColor;
currRow.style.backgroundColor=selectedColor;
if (grid.rows.length > 0)
{
for (i=0; i<grid.rows.length; i++)
{
cell = grid.rows[i].cells[4];
for (j=0; j<cell.childNodes.length; j++)
{
if (cell.childNodes[j].type =="submit")
{
cell.childNodes[j].style.display = "none";
}
}
}
}
currPushButton.style.display = "block";
}else{
currRow.style.backgroundColor= currRow.oldBackgroundColor;
currPushButton.style.display = "none";
}
uncheckOthers(currCheckBox);
}
function uncheckOthers(id)
{
var elm = document.getElementsByTagName('input');
for(var i = 0; i < elm.length; i++)
{
if(elm.item(i).id.substring(id.id.lastIndexOf('_')) == id.id.substring(id.id.lastIndexOf('_')))
{
if( elm.item(i).type == "checkbox" && elm.item(i)!=id){
elm.item(i).checked = false;
}
}
}
}
</script>
asp Code:
Protected Sub grdStatusMaster_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles grdStatusMaster.RowCancelingEdit
grdStatusMaster.EditIndex = -1
grdStatusMaster.Columns.Item(4).ItemStyle.Width = 15
grdStatusMaster.Width = 450
Me.grdStatusMaster.DataSource = (CType(Session("myDatatable"), DataTable)).DefaultView
Me.grdStatusMaster.DataBind()
End Sub
Protected Sub grdStatusMaster_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grdStatusMaster.RowEditing
With grdStatusMaster
.EditIndex = e.NewEditIndex
.Width = 560
.Columns.Item(4).ItemStyle.Width = 125
If Me.IsPostBack Then
Me.grdStatusMaster.DataSource = (CType(Session("myDatatable"), DataTable)).DefaultView
Me.grdStatusMaster.DataBind()
Dim descTB As TextBox
Dim rowCheckbox As CheckBox
Dim strScript As String
descTB = .Rows(.EditIndex).Cells(2).FindControl("txtdesc")
rowCheckbox = .Rows(.EditIndex).Cells(0).FindControl("ChkSelect")
strScript = "<script language=""JavaScript"">" & vbCrLf & _
vbTab & "document.getElementById('" & descTB.ClientID & "')" & ".focus();" & _
vbCrLf & vbTab & "document.getElementById('" & descTB.ClientID & "')" & ".select();" & _
vbCrLf & vbTab & "document.getElementById('" & rowCheckbox.ClientID & "')" & ".checked = true;" & _
vbCrLf & "<" & "/script>"
Page.ClientScript.RegisterStartupScript(GetType(String), "HighLightText", strScript)
End If
End With
End Sub
The code above will only allow user to check one row in gridview ( Success )
and also make the button be "none" or "block" ( partially success )
Now my problem is the edit button work nicely and also the cancel button.
The problem is it will not effect to update button.
how to rectify my problem ?
Thanks a million :-)
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Mar 12th, 2009, 07:51 AM
#4
Re: [2005] set button display to none
Are you handling the RowUpdating event? What does the markup look like?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|