.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

Disable past date, showing URL in gridview and validate generated number

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


I've got 3 problems and I can't find the solution so that's why I'm here.
1. I've got a calander for adding a product to my shop. How can I make sure that you can't select a date in the past?
2. I have a gridview, and I have added a hyperlinkfield in access. When I'm filling up my gridview it doesn't show a link, it shows this:
example= www.Groezrock.be#http://www.Groezrock.be#
3. I've added a label and a textbox on my guestbook page. It says "Please fill in the number in the textbox -label that generates 4 random number- txtbox.
For filling up the textbox I use this code:

        Dim randObj As New Random
        lblVraag.Text = (randObj.Next(1001, 10000).ToString)

The problem is, when I fill in the number, it always gives me the validation error "Numbers don't match" which I added myself.

        If txtnumbers.Text = lblnumbers.Text Then
            lblFout.Text = "Numbers don't match."

End If

View Complete Post

More Related Resource Links

GridView Pager not showing proper number of rows

I have created an out-of-the-box  (default everything) ASP.NET Dynamic Data Entities Web Site using VS2010, C# and the .NET Framework 4. Created an ADO.NET Entity Data Model based off a MS SQL 2008 R2 database and registered that EF data model for my dynamic data. Everything works great except for the one change I would like to make. By default, the GridViewPager.ascx file provides the values 5, 10, 15 and 20 in the dropdown for GridView's "Results per page" option. I would like to change that to 10, 20, 30 and 40 - with 40 being the default selected option. I went to the code behind file and modified it to have the values I am wanting. Those values now show in the dropdown, and work if I select them. Problem: when the page is first rendered only 10 rows will show. How can I change this? Any help would be greatly appreciated.   Thanks

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.

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??

Gridview extends past edge of div and page when editing users


I have a gridview pulling all data from one user. This gridview has an edit button and when that is clicked the gridview becomes too wide for the div/screen and I get a scroll bar. Since this gridview can only have one user in it anyway is it possible to display each field on seperate lines instead?

Showing the rows of a gridview as hyperlinks


Hi all, 
In the following code i have to continuing showing the rows of the gridview as links. For example: the user will click on a customer and will see more detailed information. Please suggest how to continue with an example. Thank you

    protected void Button1_Click(object sender, EventArgs e)
        //List<Customer> customersresult = new List<Customer>(); does not match the type here
        CustomerWebServiceClient.Customer[] cust;
        CustomerWebServiceClient.CustomerWebService client = new CustomerWebServiceClient.CustomerWebService();
        cust = client.GetCustomerContract(TextBox1.Text); //coming across now..
        //if (cust.va) validate if there is data
        GridView1.DataSource = cust;

// this is showing the gridview with the data coming. What would be next steps to show the rows as hyperlinks.

Thank you

validate the selection of atleast one checkbox in the gridview using javascript


 i have a gridview with a checkbox in the templatefield as given  below,

<asp:GridView runat="server" ID="gvAsgnHw"  AutoGenerateColumns="False"   >
        <asp:CheckBox id="cbAsgnHwGrid"   runat="server" /> </ItemTemplate></asp:TemplateField>

         <asp:BoundField DataField="Resource_id" HeaderText="Resource ID"/>
        <asp:BoundField DataField="Resource_name" HeaderText="Hardware Name" />

I want to check the selection of atleast one checkbox on a button click using javascript.
pls help

How to disable fields in a GridView when you change the listbox options?

 Hi all I am trying to apply the same logic I applied to a FormView. Here is what I do:I have a DropDownListBox as one of my FormView fields and when I choose a specific option the fields inside my FormView are enabled/disabled according to the options chosen. Well I havent been able to apply that concept to a GridView. Here is my code to the FormView:protected void ItemFormView_DataBound(object sender, EventArgs e) { DropDownList ddlConfigType = ItemFormView.FindControl("ddlConfigTypes") as DropDownList; if (ddlConfigType != null) { if (ItemFormView.CurrentMode == FormViewMode.Edit) { DisableNAFields_EditMode(ddlConfigType.SelectedItem.Text); } } }private void DisableNAFields_EditMode(string configType) { TextBox txtboxScope = ItemFormView.FindControl("txtboxScope") as TextBox; if (configType == "registry") { txtboxScope.Enabled = false; } } Is there a GridView mode enumeration? How do I achieve the same goal? Thank you

Ajax Calendar Extender Question (about disable pass date)

HiI am wondering if it has anyway to disable the past day on the Ajax Calendar Control, previously, when we use CalendarExtender, we need to put a asp:Calendar and a textbox. we can use FindControl to find the calendar control and disable the past days.I am wondering is there anyway  could do the same stuff?Another question is how could I read the user selected date to the Date variable?Do i need to convert the date from the TargetControl ? E.g. Convert.ToDateTime(txt_DATE.text) ?Please let me know if you want me to explain more.Many thanksChi 

Gridview not showing - Microsoft Web Developer 2010

I have a very simple web page. It was a grid View with a datasource associated with it which calls an SQL stored procedure. When creating the datasource, I tested it and it came back with results so the datasource work correctly. When I refresh schema for the Gridview, save the page and compile, the web page is blank. There are no errors. On the properties of the GridView Visible=true. I cannot understand why this is happening. Does anyone know of a reason why this would happen or how I could troubleshoot it further?

Gridview not showing alternate colors

I am trying to make the colors different for every line, so lets say one line white and the next light grey. I tried it in the gridview using autoformatting direct formatting css formatting but it has no effect on the display! The lines are all white! Only formatting to work is the header formatting. Who can help? For CSS, I have<RowStyle CssClass="gridRow" /> <HeaderStyle CssClass="gridHeaderSort" /> <AlternatingRowStyle CssClass="gridAlternateRow" /> and .gridAlternateRow {  background-color: #DCDCDC; /*LightGrey*/  } .gridRow {   background-color: White; } .gridHeaderSort { background-color: #DCDCDC; color: Black; font-weight: bold; text-align: left; }   I tried with every option - without any effect. Visual Studio 2005, IE6. No change in the preview, no change when running. I tried with a font option for the row - this one is evaluated. I tried setting it programmatically - no change.

Showing Solr XML results in gridview using xmldatasource

I have the XML below, generated by Apache Solr.I want to assign the results (2 <doc>nodes in this case) to a gridview using an XML datasource.<response>-<lst name="responseHeader">    <int name="status">0</int>    <int name="QTime">0</int>    <lst name="params">        <str name="facet">true</str>        <str name="fl">        id,title,city,score,location_rating,introtext,location_rating_total,themes,features,official,services        </str>        <str name="indent">on</str>        <str name="start">0</str>        <str name="q">*:*</str>        <arr name="facet.field">            <str>province_raw</str>            <str>services_raw</str>            <str>themes_raw</str>           &

validate date/time span and alow only time input

Hi, I have 2 small questions: 1. How can I  make a filed for input only time without date? 2. I need to make a date/time validation in form like: if(time between begin_date_field  and end_date_field) is not in intersection (time between begin_date_field  and end_date_field) of any item in list) Can I make this validation only using VisualStudio2010 or is there a simpler way? ( I need this for small list for managing reservations of conference rooms )

gridview date

Hii have a gridview in  each row of gridview row i hve 2 columns  in each row i  need a button  to enter date , when i click button one calender shld popup and data shld be display at  end of the row

XMLDatasource with gridview: only first result is showing

My gridview is showing only the first result from the data I have assigned to the XMLDatasource.This is this XML:<response>-<lst name="responseHeader">    <int name="status">0</int>    <int name="QTime">0</int>    <lst name="params">        <str name="facet">true</str>        <str name="fl">        id,title,city,score,location_rating,introtext,location_rating_total,themes,features,official,services        </str>        <str name="indent">on</str>        <str name="start">0</str>        <str name="q">*:*</str>        <arr name="facet.field">            <str>province_raw</str>            <str>services_raw</str>            <str>themes_raw</str>            <str>features_raw</st

Adding a number to a date to give a future date

Gooday     , how can i write this ,inorder to add an int' to a 'date' type and receice a 'date' type as an answer . I tried the below code but without succsess.  thanks   rob                                                                                                                                                                                                 UPDATE  

showing number of items in sub folder

Hi, In "All Site Content", we can see the number of items under each folder. But when we open the folder for example Documents, if it has sub folders, there it does not list the number of items. How to list the number of items in the sub folders. Thank you

disable autopostback of checkbox inside of GridView during SelectedIndexChanged of ListView

Hi, I hope my question is clear: I have a checkbox placed inside a gridview: <GridView><asp:TemplateField HeaderText="Driver">   <ItemTemplate>       <asp:CheckBox ID="CheckBoxDriver" AutoPostBack="true" OnCheckedChanged="GridView_Persons_SelectedIndexChanged" ValidationGroup='<%# Eval("ID") + "-" +((GridViewRow)Container).RowIndex %>' CssClass="CXDriver" runat="server" Checked='false' />   </ItemTemplate>       </GridView> For example: A listViewItem 1 has 3 drivers are checked, A listViewItem 2 has 2 drivers are checked. Therefore, if changing the selectedIndex of the list, the checkbox indexChanged event will be fired. How could I disable the autopostback of the checkbox during the listview item changed. Thanks in advance
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