.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to Disable Buttons in EmptyDataTemplate?

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net

hi i want to disable some buttons in my emptydata template. i tried using this code but it cant find the control. thus returning an error Specified argument was out of the range of valid values.

Button btnsaveini = (Button)grdNonSerialized.Controls[0].Controls[0].FindControl("btnSave1");

btnsaveini.Enabled = false;


thanks in advance.


View Complete Post

More Related Resource Links

MVVM - Refreshing buttons enable/disable state


Hi everyone... something is working wrong on my MVVM App.

I have a view with the following buttons

    <Button Command="{Binding ShowPlayersCommand}">Show Users</Button>
    <Button Command="{Binding ExitCommand}">Close</Button>

The idea is to show a new window when

Enable/Disable Buttons based on another control property


Say i have a tab control that displays data of various types, eg EditorTabViewModel (eg. code view of WYSIWYG), PreviewTabViewModel (eg. preview of WYSIWYG) both inheriting from TabViewModel . The implementation is similar to the tutorial on MSDN

I want to enable/disable buttons depending on the active tab, whether its an EditorTabViewModel or a PreviewTabViewModel and maybe based even on properties of the ViewModel?. How can I achieve this?

Enable/Disable "Edit" and "Check In" buttons in Ribbon

We want to enable or disable "Edit" or "check in" buttons in ribbon depending upon code run in C#. We have visited a lot of resource but mostly describes for custom buttons. We need to do this for buttons provided out of the box. Any help?

Gridview with Radio Buttons

As now, Radio buttons are HTML controls, I am not able to get it on server side. When user select any radio button and press submit, Control will not available at code behind, you can use "e.Item.FindControl" as it is not "runat='server'". I want ID "Primary Key" value for selected radio button. To achive this I took the help of Javascript. I wrote javascript function that sets the values of "Primary Key" in hidden field when user clicks on any radio button. Now when user clicks on Submit button, user can get selected value froim hidden field.

Use Membership but bypass / disable password usage for users


I have an application that does LDAP authentication. The authentication is done on the code behind page of my Login.aspx page. Once the user passes LDAP authentication, a cookie is set and I redirect:

FormsAuthentication.RedirectFromLoginPage(UserName.Text, False)

I would like to setup membership in my application and keep track of some user information. But due to company security requirements, I cannot store user passwords on my application. That must stay on the LDAP server only.

Is there a way to store users but disable password storage on the aspnet_membership table?

Buttons with Mouse-Over Behaviors - Redux

I recently posted some CSS and HTML snippets for a buttons collection I was using for a Menu style UI Scott Koon from www.LazyCoder.com posted a comment with a better way (thanks Scott). This way I don't have to set the CSS Class for each button. Just contain them in a div. Here is the [...] Read More......(read more)

GridView EmptyDataTemplate and FindControl Method


I have 2 textboxes, a dropdownlist and a button in the EmptyDataTemplate of a GridView control and when I click the button I want to get the text from the text boxes and DropDownList put it in the QueryString of a URL i redirect to, but I can't work out why the FindControl method cannot find the controls.  I am using the following code:

Dim ddlNumPpl As DropDownList = GridView1.FindControl("ddlNumPpl")

I get an "Object reference not set to an instance of an object" error though when I try to refer to the SelectedValue property of it though.  I would be very grateful if someone could let me know why the FindControl method can't find the control and what I should do to rectify it.

Many Thanks (in advance),


Disable check box in a gridview does not working



I have a check box in a template field in a gridview.

Based on some condition, I want those check boxs to  be enable and disable.

I am trying the below code but does working..

 protected void GVstudents_RowDataBound(object sender, GridViewRowEventArgs e)
              if (e.Row.RowType == DataControlRowType.DataRow)
                    string studentID = GVstudents.DataKeys[0].Value.ToString();
                    int stdID = Convert.ToInt32(studentID);
                    int schID = profile.getSchoolIDByStudentID(stdID);
                    int tchrID = profile.getTeacherIDByStudentID(stdID);

                    if (patti.chkIsTeacherPaid(stdID, schID, tchrID))
                        CheckBox cb = (CheckBox)e.Row.FindControl("chkTeacherPayment");
                        cb.Enabled = false;
                        cb.Checked = true;


any help??

Disable filtering on a Dynamic Data list view.


I have an entity set of NotificationTemplates, and each one of these has a collection of zero-many SmsTemplate entities. When editing or viewing a NotificationTemplate, I have a link to View SMS Templates. That link takes me to a List view for the SmsTemplates entity set, filtered for the NotificationTemplate I was viewing.

How can I prevent the user changing this filter to show SmsTemplates for another NotificationTemplate? That is, I want the filter, but it must be read only. The drop-down just mustn't drop down, it must just display the name of the NotificationTemplate that these SmsTemplates belong to. To view SmsTemplates for another NotificationTemplate, the user must click View SMS Templates from that other template.

This was originally asked by myself on SatckOverflow at: http://stackoverflow.com/questions/3514373/disable-filtering-on-a-dynamic-data-list-view

HTML Table Disable


I have a HTML Table that I use to place the control in so they display nicely on my Web Form.  I also use the Disable method to keep unwanted users from editing those controls based on their log in information, however I still want the information to be displayed for their review.

The information is displayed for example in the Text Boxes, however when they hit Enter on the form because the table is disabled for some reason the information is lost when I do my update to the SQL Server (the text box shows "")?

Why is it I can see the information on the screen, but the text box shows empty when hitting enter on the form?



Checkbox disable/enable


I hope someone can be kind enough to help/advise me with this.

I have a web form with multiple checkboxes on it , with one of the checkboxes as the main (controlling) checkbox.  By this I mean that when this main checkbox is checked then all the other checkboxes need to be disable and when its unchecked these other checkboxes need to be enable.

I've found (plenty of) code to do this in javascript but i would really prefer to to it in vb(.net), if possible.

I hope all this makes sense to you.


single form multiple buttons in MVC


In a single page  has two buttons , ddown and tempname.

I wrote two actionresult separetly each one for ddown and tempname.

I need one is post and another one is get method. so i gave like

1. Get Method


        [AcceptParameter(Name = "button", Value = "tempname")]
        public ActionResult ddown_tempname(string statusName, NewsLetterAdminViewModel viewModel)

return View();



2.Post Method


        [AcceptParameter(Name = "button", Value = "ddown")]
        public ActionResult ddown(string statusName, string button, NewsLetterAdminViewModel viewModel, FormCollection collection)

return View();



if i call the post method its worked well. but if i call the get method, the code does not execute. the brea

Mission Impossible? Use Javascript to Disable a Multi-Line Rich Text Field


Hey Community,

Here's a tough one that I have struggled with and so far have not been able to find an answer for - how do you use Javascript to disable a multi-line rich text field.  I have customized a SP Edit form by adding a CEWP.  In the CEWP I have added the Javascript below (only a partial code sample provided) to disable several fields in the form.  The code works fine for single line text fields but it does not work for multi-line rich text fields.  Any suggestions?

<script language="javascript">
//This runs the function when the form first loads

//This locks the fields the users should not modify
function lockFields()
  var theInputTFTitle = getTagFromIdentifierAndTitle("Input","TextField","Title");
  theInputTFTitle.readOnly = true;
  theInputTFTitle.style.color = 'gray';
  //alert(" Value: " + theInputTFTitle.value);//for testing

   var theInputDDLReplyStatus = getTagFromIdentifierAndTitle("select","DropDownChoice","Reply Status");
  theInputDDLReplyStatus.disabled = true;
  //alert(" Value: " + theInputDDLReplyStatus.value);//for testing

  var theInpu

Ajax.BeginForm with multiple buttons


can i have more than one AjaxOptions in Ajax.BeginForm targetting different controls?

Actually I want to exchange data between two listboxes placed in a single ajax.beginform.

How to do it..................help me.

Disable VS2005 Undo?


Does anyone know if there is a way to disable the Undo feature within VS2005?  I searched through the options but nothing jumped out at me.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend