.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

Checkbox Value Problem

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

Hi Guys,

I have a problem with razor in a checkbox. It does not get a checked value.

Here is the code:

PageData["Title"] = "Edit Your Profile - ";

var db = Database.OpenFile("mySite.sdf");
var selectQuerySingle = "SELECT * FROM UserProfiles, webpages_Membership WHERE UserProfiles.UserId = webpages_Membership.UserId AND UserProfiles.UserId=@0 AND webpages_Membership.UserId=@0 ";
var UserId = UrlData[0];

if (UserId.IsEmpty())

var row = db.QuerySingle(selectQuerySingle, UserId);

var firstname = row.firstname;
var lastname = row.lastname;
var email = row.email;
var phone = row.phone;
var address = row.address;
var city = row.city;
var zipcode = row.zipcode;
var country = row.country;
var isconfirmed = "";

if (IsPost)

firstname = Request["firstname

View Complete Post

More Related Resource Links

Problem bounding data to

HiI want to find the correct way to bound data to a asp:checkboxI use this checkbox in the itemtemplate of a detailsview and this detailsview is bounded to a linqdatasource.<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" DataSourceID="LinqDataSource2" EnableModelValidation="True"> <Fields> <asp:TemplateField> <ItemTemplate> <table style="width: 60%;"> <tr> <td> <asp:Label ID="Label1" runat="server" Text="<%#Eval("Fname")%>"></asp:Label> </td> <td> <asp:CheckBox ID="CheckBox1" runat="server" Checked="<%#Eval("isActive")%>" /> </td> </tr> </table> </ItemTemplate> </asp:TemplateField>

gridview checkbox group by problem



i am using this component http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm and it works great. The problem im facing is that i need to add a checkbox column(added dinamically) and group by that checkbox. I have added the checkbox using:

        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
            OnSorting="GridView2_Sorting" >
                <asp:BoundField DataField="Client" HeaderText="Client" SortExpression="Client" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="BilledBy" HeaderText="BilledBy" SortExpression="BilledBy" />
                        <asp:CheckBox ID="Include" runat="server" Text='<%# Eval("Project") %>' />

And as specified in the link, i use this code to make the grouping:

The dreaded Checkbox Empty Validation problem


I've seen zillions of postings on how to deal with the issue where you need to validate a Checkbox to ensure the user has checked it "true" or "on", or "checked".  Useful for making them confirm they have read and/or agree to something.

It seems unfortunate that the base controls don't handle this, and many others agree with me...nonetheless...

I have tried to implement a hybrid of some of these solutions.  Anyway, here's what I've put together, and I am not skilled enough to know why this does not work.  It doesn't generate any errors, and when I look at the rendered HTML via "view page source", there is nothing obvious that I see...for example, all the controls appear to be there and seem to render the same as any of the static HTML controls that are also on the page.

Anyone able to enlighten me?  Thanks in advance:

1.  In a utility library, I create a class that inherits from the CheckBox class, so that I can dynamically create it in code.  (I don't want to bother creating a UserControl for this because it seems like overkill to implement a single missing (my opinion) property.  I lifed the equivalent of this code from other forum posts.

namespace CommonClasses
    //extend the standar

problem to get checkbox value in gridview


Hai everyone, im new in asp.net

im trying to get the entire row value when click on the check box and press submit. but i seems like nothing happen.

HTML code:

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            <asp:TemplateField HeaderText="Select">
            <asp:CheckBox ID="chk1" runat="server"/>

            <asp:BoundField DataField="PakejID" HeaderText="PakejID" 
                            SortExpression="PakejID" />
            <asp:BoundField DataField="Name" HeaderText="Name" 
                            SortExpression="Name" />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />


button click event :

protected void Button1_Click(object sender, EventArgs e)
        StringBuilder str = new StringBuilder();

        for (int i = 0; i < GridView1.Rows.Count; i++)
            GridViewRow row = GridView1.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chk1")).Checked;

            if (isChecked)

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Regrading Sharpoint 2010 problem and solutions

We can write your question and problem on this blogger.you get ans.use.

This sharpoint 2010 problem solving threads

Hi friend,

you can use this thread to solving problem and solutions.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

Strange Photo upload problem


I'm working project it's live on shared hosting

we'er uploading photos to a file on the server everything works fine the photo is resized renamed and sent to the folder

the upload page returns the thumbnail and the full size photo it's there all the photos have to be approved by an admin

twice now after they have been approved they disapear I checked the folder they are not there could there be anywhere

on the server they could get hung up before they go into the folder I have it setup so when you delete the data base entry it deletes the photo from the folder othe than that you need to open the folder and delete the photo this has hapened twice now I tried to recreate it with no luck

thaks for your help in advance

ASP.Net Caching problem ??


I'm having a problem with an asp.net 3.0 application using a gridview to display data.  The problem seems to be that despite a brand new .selectCommand being sent to the sqlDataSource, the gridview starts displaying data from *someone else's* query.  For example, user A is logged in and will be working fine until a few page submissions later when the gridview data starts suddenly showing information that belongs to another user. 

This is my first asp.net application, though I've been working with classic asp and ADO for years so I'm used to sending a SQL string and getting back the results from that string.  Apparently there is a complex caching system which is interferring which I do not at all understand so at this point I just want to stop the server from caching any data whatsoever.  Is this possible?

Any and all help will be much appreciated!!

Could some one tell me whats the Problem with this String Manipulation ??? C#.net



I store some values from code behind to a label which is Hidden !

<asp:Label ID="lbl_Hidden" runat="server" Visible = "false"></asp:Label>

and at the page load event i retrieve the value of the label & assign it to a string !

stringvalue = lbl_Hidden.Text;

Now i dont know why this manipulation does'nt work !

I've a character 'A' in the string and i'm unable to replace it with a space !

stringvalue.Replace(A, " ");

Wot do u think abt it ????

RaiseEvent problem


I have a parent page ProdView.aspx and two static UserControls, UC1 and UC2. Each UC is in an Ajax accordion pane and the accordion inside an updatepanel.

UC1 has a Gridview footer with couple of textboxes and a link button that fires an Add Row insert procedure. I want to Raise an event that will rebind the UC2 after the row insert in UC1.

First I created the sub delegate and event in UC1:

  • Public Delegate Sub MyRefresh(ByVal sender As Object, ByVal e As CommandEventArgs)
  • Public Event Refresh_UC1 As MyRefresh

In the same UC1 the Insert procedure that fires the insert and RaiseEvent:

Sub PricingGrid_Insert(ByVal sender As System.Object, ByVal e As EventArgs)
       Dim myConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)
       Dim myCom As SqlCommand = New SqlCommand("AddRow", myConn)
       myCom.CommandText = "AddRow"
       myCom.CommandType = CommandType.StoredProcedure


Gridview Enable Selection Problem



I have a gridview with Enable selection and Enable Paging equals to TRUE.

I also set the PageSize of my gridview to 4 so that I only displays 4 rows per page.

The problem is when I click the pager in the bottom of my gridview, my gridview is disappearing and no records appear.

Here is code behind of my gridview:

If e.Row.RowType = DataControlRowType.DataRow Then
                e.Row.Attributes("style") = "cursor:pointer"

                e.Row.Cells(2).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(3).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(4).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(5).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(6).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
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