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

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

spgridview RowDataBound event returning cell values as empty

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :SharePoint

i am working with SPGridView to display Announcements. User should be able to edit his own created Announcements.Remaining Items shouldnt be having edit option.

i created SPGridView Columns :

                SPBoundField Title = new SPBoundField();
                Title.HeaderText = "Title";
                Title.HeaderStyle.Font.Bold = true;
                Title.DataField = "Title";

                SPBoundField Description = new SPBoundField();
                Description.HeaderText = "Description";
                Description.DataField = "Description";


View Complete Post

More Related Resource Links

Gridview RowCommand Event returning null values

HiI'm trying to retreive values entered by users in the textboxes in the footer of the gridview and insert these values into another sql table.My code is as follows :-protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)    {       if(e.CommandName.Equals("addnew"))       {                       TextBox t1 = (TextBox)GridView2.FooterRow.FindControl("tfrm");            string frm = t1.Text;            TextBox t2 = (TextBox)GridView2.FooterRow.FindControl("tsub");            string sub = t2.Text;            string cmd = "insert into suggestions values('" + frm + "','" + sub + "','c','c')";            con.Open();            SqlCommand com = new SqlCommand(cmd,con);            int a = com.ExecuteNonQuery();&n

Modifying MenuItemTemplate property in SPGridView using RowDataBound event


In a nutshell, I have a SPGridView using a visual web part in SP2010.  I've added it to the user control like so (SPMenuField not shown):

<SharePoint:MenuTemplate ID="TitleMenuField" runat="server">
  <SharePoint:MenuItemTemplate ID="menuitemtemplate1" runat="server" Text="Edit Post"></SharePoint:MenuIt

gridview tablecell text emptystring in RowDataBound event when editing


HI and thanks in advance.  asp.net using vb, using a codebehind page.

I have a relatively simple gridview bound to an product table that displays great.  The problem comes when I choose to edit a row.  When I do so, the gridviews' RowDataBound event fires and the values of the text properties of the tablecells in the row evaluate to "" emptystring. 

I do notice that if I break within the GridView1_RowDataBound event during a refresh of the page, the values are there.  But again, when I hit the "Edit" button in the first column (the CommandField column) .  Text properties of the cells resolve to ""

 Here is the code for the event, followed by the gridview in the form (inside an updatepanel)

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then  ' not a header, footer row.. etc.
            Dim cellProductNumber As TableCell = e.Row.Cells(3) ' ProductNumber column

'>>>>> after clicking "update", even though a value displays in the gridview,
' the cellProductNumber.Te

How can I change values in mydetailsview_ ItemInserting event

I'm inserting values with detailsview, and I want to modify one of my values and my client should not see it.

This is my detailsview:

<asp:DetailsView ID="dv_InsertTaps" Runat="server" DataSourceID="ds_InsertTaps" DataKeyNames="TapId"
AutoGenerateRows="False" DefaultMode="Insert" title="INSERTAR TAPS" OnItemInserting="dv_InsertTaps_ItemInserting">
<asp:TemplateField SortExpression="TapNumero" HeaderText="N&#186; Tap"><InsertItemTemplate>
<asp:TextBox Runat="server" Text='<%# Bind("TapNumero") %>' ID="tb_TapNumero"></asp:TextBox>
<asp:BoundField HeaderText="Valor" DataField="TapValor" SortExpression="TapValor"></asp:BoundField>
<asp:BoundField HeaderText="Alta Frecuencia" DataField="TapAF" SortExpression="TapAF"></asp:BoundField>
<asp:BoundField HeaderText="Baja Frecuencia" DataField="TapBF" SortExpression="TapBF&quo

Control Values When Returning to Page


Why do controls value not persist when returning to a page (e.g. via browser back button)?  If I set control values without utilizing a post back the controls will maintain their last value when I return to the page.  If I set a control value and then call a post back, the control value is reset to the default value when returning.

I have many pages with a gridview, and a textbox which is used to filter the gridview contents.  I set the filter textbox, filter the gridview (postback), go to another page, and when I return to the gridview page (via back button), my filter textbox is reset empty, and the gridview is the original (unfiltered) data.

What concept am I missing here?

Thanks in advance...

Values in user control fields empty when AutoEventWireup=true ?

As a BizTalk developer I'm trying to build a ASP.NET website so some obvious things might be new to me (so please be gentle). I have a web form and I have a user control on it. This user control contains a panel with some user properties that are to be stored in a database. So far nothing fancy. The user control itself contains a panel and is working fine (all code to retrieve and store the values is working). I used the default settings of creating a user control and one of them was AutoEventWireup=true. This works fine because I also have some dropdown boxes (and other fields) that need to be filled with values from the database and that happens in the Page_load event. The panel specifies the 'DefaultButton' which calls a method when clicked to save the values after the user has changed them. On this click the code of the method is called, I confirmed that, but I found out that the values of my controls on the user control (for example the Textbox control) are empty. As a non-ASP.NET developer I couldn't figure out why. So I changed some settings like AutoEventWireup to false. Off course this resulted in my dropdown boxes no longer to be initially filled, but my surprise was big to find out my controls actually contained the values the user typed in. Logically I need both the values and th

how to get values of list item being entered in ItemAdding event handler?

Hi,          i am trying to get the values being entered in a listitem in the ItemAdding eventhandler as follows, but it doesnt work. public override void ItemAdding(SPItemEventProperties properties)         {             base.ItemAdding(properties);             SPSite CurrentSite = new SPSite("http://mm-moss/np/");             SPWeb CurrentWeb = properties.OpenWeb();             SPList CurrentList = CurrentWeb.Lists[properties.ListId];             string vehicleNo = CurrentList.Items[CurrentList.Items.Count - 1]["Vehicle No"].ToString();             string  name=CurrentList.Items[CurrentList.Items.Count-1]["Name"].ToString(); } when i debug i cant get hold of the VehicleNo value. canyone help me in getting the values of the list item being entered? Thank you all.

Line chart with no breaks over empty values

I'm sure that I'm just missing a property but I can't find it.  I have a line chart with a contiguous range of dates on the X-axis.  If the series field has an empty value, I'd like to see the line plotted from the previous non-empty point to the next non-empty point rather than seeing a break in the line for that date.  Thanks in advance.Paul Turley, MVP [Hitachi Consulting] SQLServerBIBlog.com

Cube is showing empty values.

Hello,          When I do the full process for the cube, the data present the fact table getting updated properly into the cube and I had done the full process on the dimension which are part of the cube. But, when I tried to browse the cube, I am getting the empty values. Please help me on this. Thank you!! Regards, Pradeep.  

WCF service returning old values

Hi. I am developing an application with WCF services. The basic functionaloty of a screen is to provide an entry screen to add particular entity. Once save even fired It will save the data to the database and call the bind method to bind into the grid by refreshing the latest data. When I am running the site from my source (Visual Studio) , it works perfectly. When the client calls method to fetch the data the WCF service, it returns latest (added) data. But the issue comes in the server when it works with IIS. I deployed the code in the server, once the data added I am getting the old data only. But after two refresh I am getting the latest data. Could you please let me know what required to be done to get the latest record. Many Thank, Kelvin Kumar

How to call java script in grid rowdatabound event

Guys I want some help on this issue my code goes like this protected void grdResults_RowDataBound(object sender, GridViewRowEventArgs e)    {        if (e.Row.RowType == DataControlRowType.DataRow)        {                       TextBox txtQty = e.Row.Cells[1].FindControl("txtQty") as TextBox;            Label lblTWeight = e.Row.Cells[9].FindControl("lblTWeight") as Label;            Label lblTMHRS = e.Row.Cells[10].FindControl("lblTMHRS") as Label;            Label lblTLabor = e.Row.Cells[11].FindControl("lblTLabor") as Label;            Label lblTMaterial = e.Row.Cells[12].FindControl("lblTMaterial") as Label;            Label lblTCost = e.Row.Cells[13].FindControl("lblTCost") as Label;            string onComp = "getTotalComplete(document.getElementById('" + txtQty.ClientID + "'));&q

Process.Modules Not Returning Correct Values in x64

Hey All!   Here is my problem, when i use the following code:   Process hProcess = (.....); foreach (ProcessModule m in hh.Modules) { Console.WriteLine(m.ModuleName + " - " + m.BaseAddress); }   On a 32bits machine I get like 20 different values, those are the ones I use further in my program. However in a 64bits machine I only get: myexe.exe, ntdll.dll, wow64.dll, wow64win.dll and wow64cpu.dll.   I also tried EnumProcessModules, but got the same result.   How may I get the correct values I need?   My .NET exe is compiled at 32bits and the target process is also 32bits.   Thanks, Best Regards, Mywk

Custom membership provider not returning values from my web.config


I created a custom membership provider in my ASP.NET 4.0 web site, stored  in App_Code, and referenced in my web.config.

However, it doesn't appear to be pulling values out of web.config during initialization.

The code was taken from http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider, and the only modifications were changing "connectionStringName" here to the name of my connection string:

    Dim ConnectionStringSettings As ConnectionStringSettings = _

The connection string always comes back as nothing in this line:

    If ConnectionStringSettings Is Nothing OrElse ConnectionStringSettings.ConnectionString.Trim() = String.Empty Then
      Throw New ProviderException("Connection string cannot be blank.")
    End If

No matter what I change the password format to in web.config, the default value here is always used:

    Dim temp_format As String = config("passwordFormat")
    If temp_format Is Nothing Then
      temp_format = "Has

Send values to parent window on gridview click event


Hello all,

I have a form, which contains 2 textboxes. When i click on the first textbox, i have to open a child window (tool), that contains a gridview control with 2 columns (corresponding to the 2 textboxes). When the user clicks on any row in the gridview, it should send back the 2 column values back to the parent window to the corresponding 2 textboxes. Can anyone help me on how do i achieve this?

I can open the child window and get back the values using window.opener method in JS. 

But can anyone help on how to bind the JS code to the onClick of every row in the gridview. How can i activate the OnClick event of every row/alternating row item of the gridview and bind the JS code and pass each column value to that JS method? The no of columns in the gridview can vary depending upon the data? So in that case, i have to have a collection to be passed to JS code that can contain n number of column values.

Please help.

Event Handler returning unexpected Error Code



I am trying to set up an Event Handler to log errors to a table.

So in my Control Flow pane I set an Execute SQL Task with a deliberate error as follows; -

Name; - Execute SQL Task with Deliberate Error

SQLStatement; - SELECT * FROM InvalidTable


Within the Event Handler tab I created a further Execute SQL Statement based on the Event handler OnError

Name : Log

Parameter Mapping
Variable Name System:ErrorCode
Direction Input
Parameter Name 0
Parameter Size 100

SQLStatement INSERT INTO dbo.CustomSSISLog  (ErrorCode) VALUES (?)

Error Output; -

SSIS package "ErrorLogTemplate.dtsx" starting.

Error: 0xC002F210 at Execute SQL Task with Deliberate Error, Execute SQL Task: Executing the query "SELECT * FROM InvalidTable" failed with the following error: "Invalid object name 'InvalidTable'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Task failed: Execute SQL Task with Deliberate Error

Warning: 0x80019002 at ErrorLogTemplate: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of er

How Get selected cell values from gridview


How Get particular selected cell value from gridview . my grid so many cell available..

i'm created dynamic row and cell ...

Painting/Filling a specific cell using CellPainting event of datagridview



I am trying to paint a quantity column in data grid with color red, however when I do so cell alignment changes to left. 

Seems like I have to convert e.value to string in order for this to work and when I do that the cell alignment changes.

Quantity column is of type decimal.

Also I would appreciate if you can guide on how i can fill the certain columns in data grid with certain color(for ex. yellow).

 if (this.dtaGridView.Columns[7].Index ==e.ColumnIndex && e.RowIndex >= 0)




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