.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

DataGrid cells ImageUrl properties problem

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
At the outset i would like to welcome all as this is my first post on this forum :) probably i've got a simple problem for most of you, namly:   I want to dynamically replace ImageUrl into DadaGrid cell. I've already prepare a right type of field (Image Field) and this is my code:   Private 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 If e.Row.Cells(3).Text = "1" Then e.Row.Cells(3).Text = "Online" DirectCast(e.Row.Cells(4).Controls(0), Image).ImageUrl = "~/Css/green.png" 'e.Row.Cells(9).ForeColor = System.Drawing.ColorTranslator.FromHtml("#489A38") 'e.Row.ForeColor = System.Drawing.Color.LightGray Else e.Row.Cells(3).Text = "Offline" DirectCast(e.Row.Cells(4).Controls(1), Image).ImageUrl = "~/Css/red.png" End If End If End Sub And i.ve got this error: Specified argument was out of the range of valid values.Parameter name: index Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and whe

View Complete Post

More Related Resource Links

Problem with User Control Properties


I've been trying to figure out a problem that I've had for the past week and believe that the issue is something with a user control that I created. In short, the properties for the user control are recognized by intelisense when I register the control and then add it in the markup for a page. However, the values that I set in the markup are ignored by the class as if the properties don't exist.



Parent Page

 <%@ Register Src="../../controls/contactdetail.ascx" TagName="ContactDetail" TagPrefix="tfc" %>

<tfc:ContactDetail runat="server" ID="UserControlContactDetail" Title="Contact-Detail" ContactId="1580" EnableViewState="true" />   



User Control Class

Imports System.Data
Imports System.Data.SqlClient

Partial Class control_ContactDetail
    Inherits System.Web.UI.UserControl
    Public Property ContactId() As Integer
            Return _ContactId
        End Get
        Set(ByVal value As Integer)
            _ContactId = value
        End Set
    End Property
    Private _ContactId As Integer
    Public Property Title() As String
            Return _Title
        End Get

Problem changing/upgrading properties on WebParts that have already been deployed and added to Share

I have created two custom webparts which I deploy as a Feature within a Solution.  These webparts have been added to various pages on my site.  Due to design changes, I upgraded the webparts with some new functionality and some other changes to the webpart properties, such as the WebPart title, title icon and catalog icon.  After I have retracted/deleted the old solution and re-deployed the new solution (and activated the feature) the webparts have been upgraded fine, however, the webpart properties were not changed for any webparts that were already added to pages.  I can add new instances of the webparts and they have the updated properties (and also show correctly in the wp gallery and catalog). Is there a step I am missing in order to upgrade any webparts (namely the properties) that have already been added to pages?  Or is this something I have to take care of programmatically somehow to workaround the upgrade problem?

problem with datagrid

I am trying to create datagrids dynamically using Datagrid Array.But I am getting exception while setting Datasource.  Do anybody have the solution for this? Code  using(SqlDataAdapter da =new SqlDataAdapter(cmd1))      {       DataSet ds =new DataSet();       da.Fill(ds);              for(int i=ds.Tables.Count;i >=1;i--)       {        int j=ds.Tables.Count;        DataGrid[] dgd=new DataGrid[i];        DataGrid DataGrid[i]= new DataGrid();        DataView dv1=new DataView(ds.Tables[i-1]);        dgd[i].DataSource=dv1;//    Exception        dgd[i].DataBind();        plh1.Controls.Add(dgd[i]);       }      } 

WPF get selected cells on sorted datagrid

hello, how can i get the selected rows - and then each (visible) cell separately on a sorted datagrid? something like datagrid.SelectedCells[i][j], but with sorting taken onto account. Thanks

Problem binding business objects to custom user control properties

I have created a user control (supplierPicker) intended to allows a supplier database to be searched and a supplier selected. I want to be able to use this control in a number of other user controls, by binding the suppplierID property of the supplierPicker to a supplierID property in a business object, which is set as the datacontext of the parent user control. When I do this, and there is a supplierID specified in the business ofbject, the binding sets the supplierID in the supplierPicker control and it shows the correct supplier name in the textbox. However when the supplierID DependencyProperty is changed from within the supplierPicker the newly selected supplier name is shown in the TextBox, but the SupplierID does not propogate back to the business object. Other controls on the parent form work fine, so the binding to the business object seems to be ok. Any pointers as to what I'm doing wrong here would be grately appreciated.  This one has been driving me nuts for days! Snipped code for the supplier picker:         public partial class SupplierPicker : UserControl, INotifyPropertyChanged     {         public static DependencyProperty SupplierIDProperty;         public event PropertyChangedEventHandler PropertyChan

DataGrid control properties not updating on resize event


I have a DataGrid control on a form and I'm binding it to an ArrayList that is populated dynamically as the user scrolls.  The array list is pre-populated with blank records equal in number to the number of records in the DB.  As the user scrolls, if they stop in a place where there are blank records I populate that data from the DB.  I'm using the VisibleRowCount and VertScrollBar.Value properties to determine where I am in the DataGrid.  


The problem is that if I scroll to the bottom of the control then maximize the control it's resize event fires, the VertScrollBar is redrawn proportionally to the number of records, but the Value and VisibleRowCount remain unchanged.  If I then grab and scroll the scroll bar up then back down to the bottom, the Value and VisibleRowCount update correctly.  Is there a way for me to get these values some other way or to force the scroll bar to refresh/update manually?

Datagrid CellStyle vertical align problem


Im using the WPF toolkit when I set a textcolum cell style to align the text to the center vertically it becomes very hard to select the text

without the cellstyle I can just click anywhere in the cell and begin editing the text in there, but with the cellstyle you have a very limited area in the cell where you can select the text field

does anyone have any way to fix this?

                      <Style TargetType="{x:Type dg:DataGridCell}">
                          <Setter Property="VerticalAlignment" Value="Center"></Setter>

How to loop on controls in cells of WPF DataGrid?


How to loop on controls in cells of WPF DataGrid to read values from and append events to?


Content Type and Word properties problem



I defined a Site collection content type that have some required properties  and added it to a document library .

When we create a word document and then we try to save it in that document library , we have this message saying that some properties values are missing if we don't fill the mandatory ones

by pressing the button "Go to Document Information Panel"  the  “Retry  save” 

Dimension properties problem


This is off of the Adventure Works DB. 

If you look at the Dimension Properties for Mountain-100 Silver, 38 it shows NULL for the [Category]
[Product].[Product Categories].[Category] = (null)
[Product].[Product Categories].[Subcategory] = Mountain Bikes
[Product].[Product Categories].[Model Name] = Mountain-100

But if you look at the created measure it shows what I would expect in the Dimension property [Measures].[Prt Mod Name]

Why doesn't this show up in the dimension property and how could I go about fixing this so it does?






[Measures].[Prt Cat] as

WPF datagrid Tab Navigation problem not following tab index order



I have designed a wpf page with 3 textbox than a datagrid than again a text box

and I have set the tabindex to first 3 testbox 1, 2, 3, than 4 to datagrid and 5 to last testbox

But when I run page and press tab to navigate,first three textbox are ok they follow tabindex but when I tab to navigate to datagrid it jumps to forth textbox and again on next tab go to datagrid. means after navigating all of the four textbox its go to girdview.

Please tell me how I can set tab order?

Problem in properties.AfterProperties with respect to DateTime field.

Hi all,

I have an event handler, ItemAdding and I am trying to get start and end for "Calendar List".

For,  StartDate = Convert.ToDateTime(properties.AfterProperties["EventDate"]); its showing next day.
For e.g, User took 5 day vacation from 12 Jan to 16 Jan. But for StartDate its showing 13 Jan and also for end date i.e. 17th.

I tried some reserach on about this issue: 

But in my case, properties.ListItem is null.
SPListItem currentItem = properties.ListItem;
DateTime beforeValue = System.Convert.ToDateTime(currentItem.Fields[displayName].GetFieldValueForEdit(currentItem[displayName]));
properties.AfterProperties[internalFieldName] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(beforeValue.AddDays(1)).ToString();

This is my complete code for ItemAdding

browser compatibility problem with datagrid with fixed header using CSS way


Hi Everybody,

I am trying to create a datagrid with fixed header and I was using the CSS way to implement this using:


However, this only works in IE and not in FF. The other alternative that I found was to create the header in a separate table and to use scrollbars on the datagrid. But, I want to stick to the first option and want to make it work on both browsers. The problem is I don't know how. Any inputs on this is greatly appriciated.


WPF datagrid Tab Navigation problem not following tab index order



I have designed a wpf page. But I not able to set Proper Tab Navigation on it. Controls (Specialy datagrid) on the page are not following tab index. 

It has a group box inside which there is a grid. this grid has rows and columns. In first three rows contains textboxes. 4th row contains  the datagrid forth row spans to 5 cols. in next row it agains has textbox and after that it has 3 buttons

Following is the design view, Run time view with tabindex which I have given to them and arrows show the index they are following.

I am loading datagrid with a object of list of items which has one object of type item. so as per my thinking it is not empty it has data in it. as you can see in run time view

Datagrid with Combobox Lookup (CollectionViewSource) -- Problem Saving Combobox Changes


I've developed a simple WPF application consisting of a four-column datagrid.  One of the four columns is a combobox that looks up by an id into a second table.

I can make changes to the other columns and they save just fine.  When I make a change to the combobox, it's not changed in the database.

I'm either missing something in the SelectionChanged handler or totally missing something else.

I've googled to the nth degree and haven't found any definite answers.

Any ideas?



Cindy Rae



<Window x:Class="trialWWSF2.MainWindow"
        Title="MainWindow" Height="403" Width="525" xmlns:my="clr-namespace:trialWWSF2" Loaded="Window_Loaded">
        <my:WWSF x:Key="wWSF" />
        <CollectionViewSource x:Key="categoriesViewSource" Source="{Binding Path=Categories, Source={S

Edit GridView Individual Cells in ASP.NET

The ASP.NET GridView allows for a row of data to be edited by setting the EditIndex property of the GridView, placing the entire row in edit mode.

You may not want the entire row in edit mode if you are using DropDownList controls for several columns in the EditItemTemplate. If each DropDownList has many options then loading them all at once may result in a sluggish page. Also, if your data structure is more like a 2 dimensional array rather than a set of rows, you may want to edit each cell individually.

Here I will demonstrate how to achieve this and also how to deal with event validation without disabling it.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.
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