.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

DataFormatString not working in GridView even if HtmlEncode="false"

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

Hello everybody,

My following bound column in GridView is not displayed with the currency formatting that I have apllied.

Please help me to find the solution. I am able to format my columns for Date but not for numbers and currency. somewhere i found that putting HtmlEncode="false" will work. But it is also not working in my case.

<asp:BoundField DataField="LoanAmount" HeaderText="Loan Amount" SortExpression="LoanAmount" DataFormatString="{0:C}" HtmlEncode="false">

 thanks in advance. please help me to find the solution.



View Complete Post

More Related Resource Links

DataFormatString in a BoundField of a GridView

I had a simple little problem - the DataFormatString="{0:0}" in a BoundField was not working

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

KeepTogether=false on table not working within rectangle


I have an rdlc report that has a table contained within a rectangle. Since I have multiple data sections within the BODY of the report, I am using rectangles to keep them separated.

Anyway, the problem is that <KeepTogether> set to false on the table is not working when the table is contained within the rectangle, causing unwanted page breaks and acting as though KeepToghther is always true. The rectangle does not have <KeepTogether>.  When the table is outside the rectangle everything works fine.

Any ideas?



Gridview check all not working in Mozila Firefox


hi all,

i has an gridview first column header is Checkbox, when i click on that all the detail column checkboxes were selected if i use IE but the same not working in Mozila Firefox

below is my code

function checkAll()
                  var totalChkBoxes = parseInt('<%= gv5.Rows.Count %>');
                  var gvControl = document.getElementById('<%= gv5.ClientID %>');
                  var gvChkBoxControl = "cbCheckProd";
                  var mainChkBox = document.getElementById("chkBoxAll");
                  var inputTypes = gvControl.getElementsByTagName("input");
                  for (var i = 0; i < inputTypes.length; i++)

Dynamically creating Gridview Template - Linkbutton Click not working



I have written some code to dynamically generate template columns for gridview which works well. However, each cell in the gridview has to be a linkbutton, which when clicked does a db update and redirects to a specific url with some parameters in it.

I have attached a click event handler to the linkbutton in the InstantiateIn method but the event does not seem to fire.

Could someone please help? the code is below -

//Dynamically creating the Grid

protected void btnAnalyze_Click(object sender, EventArgs e)

Attempting to use an HTTP handler to display pictures in gridview. It's not working, please help.

I am writing a web page that needs pictures displayed for each item.  The page works just fine except for the pictures.  I have a file called handler.ashx uploaded to the server as well.  It does not seem to be hurting anything, but it doesn't seem to help display the pictures either!  I am working with a MySQL database so I am thinking that the call for the data or the ashx page's structure itself are my problem.  I am using C# Express so there is no generic handler class to autoload and therefore my handler page is pasted together and I know the using statements are in the wrong place, but I'm new to this and I'm lost!  The following is my database table info (table is named: Yamaha), my handler.ashx page code, and the code for the final web page.  I have loaded ".jpeg" or "jpeg" into the field I added called "Image_Type"  since I have already uploaded all pictures as longblobs.  You can view the final web page here: http://www.88867honda.com/YamahaPtsSale.aspx Thanks in advance for any help, Melissa   Table info: Field TypeAttributes--> Null DefaultExtra--> Comments part_number varchar(15)  --> No     -->   description varchar(50)  --> Yes  NULL   -->   qty int(4)  --> Yes  NULL  

Gridview rowupdated not working

hi frienz,After i click edit, i will get Update and Cancel button When I viewsource, I get this <input type="submit" name="GridView1$ctl07$ctl01" value="Update" onclick="javascript:WebForm_DoPostBackWithOptions( new WebForm_PostBackOptions(&quot;GridView1$ctl07$ctl0 1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" / >&nbsp;<input type="button" value="Cancel" onclick="javascript:__doPostBack('GridView1','Canc el$5')" Cancel Works. But Update doesnt. Why? perhaps WebForm_DoPostBackWithOptions is not constructed properly. A Bug? Perhaps. So when I manually execute "__doPostBack('GridView1','Update $5')", it will call RowUpdating. Weird ! Why does this happen? but onRowupdating event not fired anybody can suggest methank u

Update a field in a gridview to False on a Button Click

 Hi, Ive got a list of records in a gridview (from an SQLDataSource) where a field value is set to True.  I've also added a "reset" button in a template field at the start of the row in the Gridview. What I would like to do is allow the user to click the reset button on a particular row and 'reset' the true value to 'false' (updating the source data). Are there any idiot proof tutorials to do this??? Many thanks for your help! Fiorano

Alert not working when used with image inside gridview

I am currently using following code to set alert on required column of my grid. When I change button type to Image the alert appear after completion action. Any quick suggestion??   My code is below.. protected void grdDelTempList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[6].Attributes.Add("onClick", "javascript:return confirm('Are You Sure?');"); } }    

The delete and edit buttons not working in gridview!

Hi everyone. I have problem with the buttons Edit and Delete in Gridview for very long time and i really need help about it.  So the when i click edit i get in edit mode and when click update the values in the row i was changing disappear but only in the gridview. When check in the Database nothing happens. The delete button not works at all, i mean when click on it only refresh the table. If see something wrong in my code please help. See how looks my page:Now here's my code in aspx:<%@ Page Language="C#" Title="Specific Search in Phone Directory" ... ... ... <asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:ThisIsMyConnection2 %>" OldValuesParameterFormatString="original_{0}" DeleteCommand="DELETE FROM [Resident] WHERE [MobileNum] = @MobileNum" InsertCommand="INSERT INTO [Resident] ([FNAME], [LNAME], [MobileNum], [HomeNum], [OfficeNum], [FaxNum]) VALUES (@FNAME, @LNAME, @MobileNum, @HomeNum, @OfficeNum, @FaxNum)" SelectCommand = "SELECT * FROM [Resident] WHERE (([FNAME] + ' ' + [LNAME] LIKE '%' + @FANDLNAME + '%'))" UpdateCommand=

How to make cause validation false for Show Edit buttons in Gridview control

  HI. I am having 2 (dept name, City)dropdownlist, 1 Save button once if we click the save then record will be displayed in grid (Gridview with ShowEditbutton =true and I have Edit logic in my page). But if I click on Edit button then if I try to update the value then it is firing a message "Select dept" because dept dropdown present in the page so I want to make cause validation false for Show Edit buttons (update and cancel). Pleaase tell me Thanks

gridview checkbox sorting not working

Hi All,I have a grid view which populates data just for viewing purpose(report) . One field shows the Active/inactive status for which I am showing a checkbox..if data in database is 1 then the checkbox will be checked otherwise it'll not be checked. This field is inactive so that the User does not check/uncheck it. The issue is that this field cannot be sorted. All the fields in the gridview are being sorted. Below is the code for the checkbox column. <asp:TemplateField HeaderText="InActive" SortExpression="Inactive"><HeaderTemplate ><asp:Label ID="lblStat" CssClass="copyLabel" Text="Inactive" CommandArgument="Inactive"                    runat="server"></asp:Label></HeaderTemplate> <ItemTemplate><asp:CheckBox runat="server" ID="chkStatus" Enabled="false"/></ItemTemplate></asp:TemplateField>I have given AllowSorting="True" in the gridview properties. The code in the gridview sorting event works fine for all other columns except the checkbox column. Please help and suggest some scenarios/links so that I can achieve sorting for the checkbox column also.Thanks in advance.

Gridview Delete not working

I just downloaded VS2010 with Framework 4.0.30319 I've bound a gridview control to a datasource, defined the select, insert, and delete SQL statements. Select and insert are working just fine thank you, but when I select the (auto-generated) Delete link, a postback occurs, but the row/record remains in the gridview. I have the one-segment key in the select statement, in an invisible column of the gidview. I've set the DataKeyNames property to this column name (CinID).  The delete query reads - DELETE FROM CallIn WHERE (CinID = Cid) I've defined the parameter Cid as the Gridview.SelectedRow, .SelectedDataKey, .SelectedIndex, and .SelectedValue, all with no joy. I created SUB Gridview.RowCommand put a breakpoint there. e.Command shows "Delete" and e.CommandArgument shows the correct row index (1). I created SUB Girdview.DeletingRow and put a breakpoint there. debug shows .SelectedRow=nothing and .SelectedDataKey=nothing (but I don't know if they *should* show something, since I'm not selecting, but rather deleting the row. The postback occurs (click), the grid refreshes, but nothing happens. I cannot figure out why the clicked-on row does not delete. Any ideas?  

hide gridview column using javascript. working in ie and firefox but In firefox, gridview data is sh


function EnableDisableGridViewColumn() {
               var AdvanceSearch = document.getElementById('<%= chkboxlist1.ClientID %>');
               var chkList = AdvanceSearch.getElementsByTagName("input");
               var dgTest = document.getElementById("gridview1")
               if (dgTest != null)
                   for (var i = 1; i < dgTest.rows.length; i++) {

                       if (chkList[0].checked == true && chkList[1].checked == true) {
                           dgTest.rows[0].cells[0].style.display = "block";

Need to hide gridview - not working


 I am trying to hide my Gridview when UpdateProgress control is being shown. Currently both the GridView and UpdateProgress contriols are being shown at same time. It works fine when I select from my DroDownList3 the 1st time (as no GridView is beings shown). On subsequent selections in the DroDownList3 control, both GridView3 and UpDateProgress control are shown.

<script type="text/javascript">
            function HideGridView2()
<cc1:TabContainer ID="TabContainer1" runat="server" Height="20px" ActiveTabIndex="0">
                    <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Current Shift" Style="font-size: xxx-small"
                            Current Shifts
                            <br />
                            <div style="height: 30px; left: 

GridView Hyper Link not working



<asp:TemplateField ShowHeader="false" ItemStyle-Width="50px">
                            <asp:HyperLink runat="server"  NavigateUrl='<% string.Format("~/Tiff.aspx?Id={0}, Eval("ID")) %>'  Target="_blank" Text="View" />

When I m trying to click on it...It is not working or not firing any event,

May I know the reasong or any code behing is require


CausesValidation="false" not working outside usercontrol


I have a aspx page with two linkbuttons and a usercontrol. One is used to save and one to cancel.

But even though I add CausesValidation="false" on the cancel linkbutton it still validate the the validationcontrols in the user control.

But if I add a dummy linkbutton inside the user control that has CausesValidation="false" it works and postback without validating.

Why can't I have the link buttons outside the user control?


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