.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

Image stretch inside a grid stops working horizontally once columns are added to grid.

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :WPF
I have a simple setup of a window. Window contains a grid, inside the grid there is an image. I want the image to always stretch across the entire cell. I've set it's Stretch property to Fill and it works fine, as long there is only one column in the parent grid. As the window is resized, the image stretches correctly. As soon as I add another column, the image stops stretching horizontally. Vertially it works just like before, horizontally it now appears with a fixed width corresponding to the width of the picture used as the source. Does not matter which column it's positioned in, and I've tried encapsulating it into another grid but behaviour does not change. It behaves the same in both Visual studio 2010 designer and at runtime. In addition when I tried to encapsulate it in a second grid, this seond grid also now has altered behavior - instead of sizing itself to it's container (both height and width are not set) as it's parent grid does, it now sizes itself to its contents - the image. But only horizontally. What is going wrong here, is this a bug or am I missing something, and any advice on how I can get the image to fill one of the cells of a grid with more then one column?

View Complete Post

More Related Resource Links

grid view image delete problem

i have a grid in which i am showing a record with image, when user delete the record the image also deleted and when it again enter the record it upload the new image but display the deleted image from the cache example: name.jpeg upload, then deleted, a different file with the name.jpeg upload, it showing the deleted one. 

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 database result is as follows DATE     code   class1 class2  class3 1/8/10     M1     10       20     30     3/8/10     V2      20       30     10      1/8/10      H1      1           2      3         7/8/10     ! ! 8/8/10     !M2    5      5      5       3/8/10     B2      4      4     4       1/8/10     V1      3      7     3       THE OUTPUT SHOULD BE AS FOLLOWS:- DATE           M1                          M2           

delete using boung field value inside grid view

I want to delete data using boung field value inside grid view, I am doing this...but it is not finding bound field value<asp:BoundField DataField="nsid" HeaderText="nsid" SortExpression="nsid" Visible="false" />protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)    {        string sid = GridView1.DataKeys[e.RowIndex]["nsid"].ToString();        SqlCommand cmdx = new SqlCommand("delete from blogreply where sid='"+sid+"'",con);        con.Open();        cmdx.ExecuteNonQuery();        con.Close();please anyone tell me how to find bound field value..

To get/set value for combo which is inside a grid

 I have a winform (.NET 3.5) that I am working on. On button click I want to be able to get/set selected value for combo which is placed inside the grid Regards, Sushant

how to give grid columns dinamically?

I am  trying to given Columns dinamically but this is not woking . pls help me

Creating a pivot of a collection and displaying it in a databound grid with dynamic columns



I'm trying to create a pivot of some data that I have about translation.

Basically what I have now is a collection of "Translation" objects which look like that :

Public Class SystemText
  Inherits Entity

#Region "Private variables"
  Private _textCategory As String
  Private _textName As String
  Private _languageCode As String
  Private _description As String
#End Region

#Region "Properties"
  Public Overridable Property TextCategory() As String

HELP ! - how to disable spesific control inside the grid view



I need to disable the "Imagebuttons" after the user click on one of them... I've sucessfully updated the table when the user click on a button using the following code on the event of row command of the gridview...


if (e.CommandName == "voter_up")
            SqlCommand voteup = new SqlCommand("update arto_comments set voteup = voteup+1 where cid=" + e.CommandArgument, con);
            SqlCommand getVup = new SqlCommand("select voteup from arto_comments where cid =" + e.CommandArgument, con);
            //lblvoteup.Text = Convert.ToString(getVup.ExecuteScalar());
            //GridView1.Rows[1].FindControl("ImageButton1"). = false;
            ImageButton1.Enabled = false;

so please how may I disable these buttons after database is updated ?

Thanx and Regards

Storing Image in database as image type and viewing it on grid view


 how can i store image into database and view it in grid view?

Webform Grid Control With Varying Columns


I will do my best to explain what I am trying to accomplish.  I am trying to create a recipe system that will pull material amounts from an already built inventory database upon request for testing purposes of the different recipe runs.  What is throwing me for a loop is that each time a user will request a recipe comparison they will have a different number of recipe trial runs for comparison purposes.  In order to do this I'm guessing you will need to generate a gridview-like control with a dynamic number of columns which would be specified on a web form page prior to arriving at the recipe formulation page which will contain the control for the recipe formulation.  As a result the user will have different columns and rows on this formulation page, with the rows being a static number of 30 (30 being maximum amount of ingredients to include in each recipe).  The columns will contain the recipes to be compared, i.e. ProductRun1, ProductRun2, ProductRun3, where the number of ProductRunX will be determined by user input.  So the user when they come to this aspx page will be presented with a blank editable grid of X columns by 30 rows deep.  The left-most column will contain the ingredient names in a drop down box for users to select to input into their recipe and the rest of the columns will be editable fields where the user can type in t

WorkflowDesigner.Load causes Grid resizing mouse cursor to stop working.


Hi all,

We have a problem where WorklowDesigner.Load() causes the WPF Grid control's resizing mouse cursor not to come up. I have demo app written if anyone wants to double check. http://cid-467e12cdf12776bc.office.live.com/self.aspx/.Public/WpfApplication6.zip


If you just run the demo, you will see the resize cursor will work when you hover over the red grid splitters. However if you go into the wfusercontrol2 control and uncomment this line //wf.Load(new System.Activities.Statements.Flowchart()); , then run the application again you will notice the resize cursor does not show up when hovering over the  grid splitter.


It seems as though under the hood somewhere this exception occurs: Could not load file or assembly 'System.Activities.Presentation.Aero, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Urgent:Create/Update Winforms grid columns and rows with config file values


I have legacy winforms datagrid , I have to add/replace columns with new values, My new column names and row values are changes as per new requirements , so I am looking to update datagrid form any config file , so in future for any new requirements , If I update my config file , it hast update existing datagrid.

Please suggest me the code; I am trying from 4 days and its urgent now.



Urgent:Create/Update Winforms grid columns and rows with config file values


I have legacy winforms datagrid , I have to add/replace columns with new values, My new column names and row values are changes as per new requirements , so I am looking to update datagrid form any config file , so in future for any new requirements , If I update my config file , it hast update existing datagrid.

Please suggest me the code; I am trying from 4 days and its urgent now.




columns and rows of grid generate dynamically



i am developing the applicaton, from which i have a grid and that grid i want to use for the insert data,

i have a page default.aspx page, in this i have a dropdownlist, according to selection of the dropdownlist, grid's cols and rows created dynamically in insert.aspx. so in page load of the insert.aspx the grid will automatically have that much of cols and rows and that all cell contain the textbox.

how can i set that dynamically....

please help me....

thanks in advance

waiting for the reply.....

Grid Inside StackPanel Sizing Issue


Hello All,


  I'm fairly new to WPF and I'm having an issue with a layout I'm trying to accomplish. I have pasted the XAML below. Briefly I have a Grid inside a stackpanel in which the grid has 3 stack panels nested below. The Grid in question is Named DetailGrid, which is not sizing correctly. In fact it's not stretching at all and is causing issues with some drag and drop functionality.The layout I'm trying to achieve is a Header/Body layout, where the header remains the same and the body is dynamic content based upon objects the user chooses to place on the detail grid/stackpanels. I know this may not be the best choice of controls for this layout, but the functionality of having all the children contrlols move dynamically when the expanders are expanded and collapsed is a desired function of the application.

Any Recommendations are greatly appreciated.


<Window x:Class="AtlasConsole.ConsoleHeader"

add image as grid column then send ID to edit on image click


hello - new to webmatrix and C# so probably playing with fire here....  

I have a page that allows a user to add, edit, list, and delete database items.  I would like to add an "edit" graphic to each row in the list.  Something like this:

    <div id="grid">@grid.GetHtml(
    columns: grid.Columns(
        grid.Column("<img src="editfield.gif" />"),

up above I have:

        var SQLForGrid = db.Query("SELECT * FROM Books");
        var grid = new WebGrid(source: SQLForGrid, defaultSort: "Title");

then when the edit image is clicked it should send the page the id of what they want to edit.

any help/ideas are appreciated.

Building a grouping Grid with GridView and ASP.NET AJAX toolkit CollapsiblePanel

I've posted an update to this post to apply on demand loading of Details data using ASP.NET AJAX PageMethods. I'm demonstrating the usage if CollapsiblePanelExtender client events on the new post. Check it out.

I admit, Matt Berseth is really inspiring me! Few days ago I pass through 2 of his great posts:

.Surrounding your Data Table and Dialog Controls with ComponentArt Styled Panels
.Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls
The first one is pure design tips one which I used for making good presentation of my demo here. The 2nd post is actually the idea.
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