.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

How can a fill a cell in a gridview in a windowsform?

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

I have a gridview in a windowsform.
There are 4 columns (A, B, C and D).
I column D is a combobox.
How can I fill this combobox at form_load with the following data: --> 

View Complete Post

More Related Resource Links

How can i add a textbox into a GridView Cell dynamically and how can i retrieve entred data

Hey, i think that the the subject can explain what i need, it's about adding a TextBox control with the code behind into a GridView, and also about how can i retrieve entered data after submitting, im using C#,Thanks.

I need to set the value of a gridview cell during update.

Hi,  I've been reading the posts here and I'm not finding, or maybe just not understanding, the answer I need so here's my problem. I have a small gridview and the update works very well. The issue is I need to have one of the fields set to a value from my code either when the record is open for undating or when the update runs.  Here is my gridview and the datasource info:<asp:GridView ID="GridViewItemLog" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" CellPadding="3" DataKeyNames="LogID" DataSourceID="SqlDataSourceItemLogEntries" GridLines="Vertical" onrowdatabound="GridViewItemLog_RowDataBound" onrowupdating="GridViewItemLog_RowUpdating" onrowediting="GridViewItemLog_RowEditing"><AlternatingRowStyle BackColor="Gainsboro" /><Columns><asp:CommandField ButtonType="Image" CancelImageUrl="~/Resources/StopSmall.png" EditImageUrl="~/Resources/EditSmall.png" ShowEditButton="True" UpdateImageUrl="~/Resources/Save.png" /><asp:Boun

Enhance SSAS so that a calculation returns multiple cells at once (Excel fill not a single cell but

I wonder if somebody can help me with the following question. I would like to create an enhancement to SSAS in a way so that one can pass in multiple values, run a calculation and in return retrieves not one but multiple cell results at the same time e.g. retSet = functionABC(inSET) where inSet is somthing like 5 4 3 6 7 3 4 4 AND retSet is 4 6 7 8 9 3 4 4 All my calculated members in MDX return a single value BUT I need to have a calculation that if called returns multiple results (a set) at once and in a way so that Excel will properly pick up on it and consequently fills multiple cells in the Pivot table. Is that possible at all and if so how? I would not mind to write a little CLR assembly to enhance the SSAS but don't know how to pass the results back. Any ideas are highly appreciated. Dirk

how to fill asp:Gridview when mouse clicked on AJAXToolkit Calendar

how to fill asp:Gridview asynchronously from the SQL database when mouse clicked on AJAXToolkit Calendar(When calendar date changed by client) Pls Help me out.Hoping for quick response Thanking You

ASP.NET GridView help!! Need to be able to scroll an individual cell up and down.

Hi everyone.  I have an ASP.NET GridView displaying the below grid.  As you can see, the column on the right has a LOT of text and it stretches the column.  I need to be able to set a fixed width for JUST that column (maybe like 200px) and have vertical scroll bars on that cell so the user could scroll down to read the rest of the text, is that possible to do?Here's my markup: <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="False" AllowPaging="True" AlternatingRowStyle-Wrap="False" CellPadding="4" ForeColor="#333333" GridLines="None"> <RowStyle Height="30px" BackColor="#EFF3FB" /> <Columns> <asp:BoundField DataField="Customer_Name" HeaderText="Customer" SortExpression="Customer" /> <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" /> <asp:BoundField DataField="Module" HeaderText

hoq to fill gridview dropdownlist from another db table

Hi, I have a gridview which gets its data from a database table now i ghave added a dropdownlist to this gridview but this dropdown should get the data from another table and should set its value automatically with a foreign key from the  gridview i have added the code like below in my rowDatabound but it just loads 1 field and then how should i get the selectedValue according to the gridview id field?? Protected Sub Friends_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)             If e.Row.RowType = DataControlRowType.DataRow Then                 Dim conn As New SqlConnection(HttpRuntime.Cache("con"))                Dim sql As String = "select ID,ListName from FriendList order by ListName asc"                Dim cmd As New SqlCommand(sql, conn)                cmd.CommandType = CommandType.Text                conn.Open()             &

Javascript code to copy specific cell of gridview row

Dears, I need a javascript code to copy the text content of a cell of a row in gridview. I have a button in each row that users click it and the text content a cell of that row should be copied in a textbox out of gridview

WpfDataGrid make cell background fill entire cell

Hi!  I'm setting DataGridColumn.CellStyle to a background color and to a horizontal alignment. If I do not set the horizontal alignment the whole cell is filled with the background color but if i set the horizontal alignment the background color only is shown behind the text in the cell. I've seen some workarounds to this problem (http://stackoverflow.com/questions/1379902/setting-column-background-in-wpf-listview-gridview, setting the Margins on the DataGrid and the Cell margin) but it does not work for me. The background is still only shown behind the text   private void ApplyCellStyle(Style defaultColumnStyle, DataGridColumn dataGridColumn, Color backgroundColor, HorizontalAlignment horizontalAlignment) { var style = new Style(typeof(DataGridCell), defaultColumnStyle); var backgroundPropertySetter = new Setter { Property = Control.BackgroundProperty, Value = new SolidColorBrush(backgroundColor) }; var horizontalAlignmentPropertySetter = new Setter { Property = FrameworkElement.HorizontalAlignmentProperty, Value = horizontalAlignment }; style.Setters.Add(horizontalAlignmentPropertySetter); style.Setters.Add(backgroundPropertySetter); dataGridColumn.CellStyle = style; }   Does anyone know a solution to this problem?    Regards, Lina

Gridview Cell Hightlight with toggling

Hi, I have a dynamically generated Gridview wherein every tablecell within the gridview is assigned a particular class(background color) at run time. Each cell has  a linkbutton and I have a onClientClick event where, I would like to highlight the container cell when the user clicks on the linkbutton.If the user clicks it back, I would it to  get back its original class/background color that it was bound with earlier. I am trying to implement this in Javascript by passing the original className but I am unable to toggle the color back to original.Please help. Here is a snippet of code. I could do it in c# but I would like to implement this in Javascript as it won't  cause postback.Thanks so much!//Linkbutton databinding event private void lb_DataBinding(Object sender, EventArgs e)     { private void lb_DataBinding(Object sender, EventArgs e)    { LinkButton l = (LinkButton)sender; l.OnClientClick = String.Format("doClick({0},{1},'{2}','{3}','{4}','{5}','{6}'); return false;", x, y, className, tbPercentSoldUpfrontSelected.ClientID, tbPercentChangeDemandSelected.ClientID, tc.ClientID, l.ClientID);} function doClick(val1, val2, val3, control1, control2, control3, control4)         {         &nbs

Gridview's cell have changed



   does anyone know if the gridview can tell you if a cell's contents have changed (during an edit) in order to determine if an update should be made against the database?

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

How to Retrieve the Hidden Cell value in GridView -- Urgent ************


Hello all,

In my GridView I have Hidden column contains ID. When User selects the rows and clicks on Delete Button( This is placed top of the Grid) Selected Rows will be deleted.

my delete button code is ...

foreach (GridViewRow dgi in Grid_Inbox.Rows){

CheckBox chkSelected = (CheckBox)dgi.FindControl("chk_Select");

if (chkSelected.Checked == true)


string strID = dgi.Cells[1].Text;

//Delete the Rows



//Binding the Grid



problem is when i am accessing through the code. getting cell value as bla

Gridview Cell Merging


Hi All,

I have a grid, where i need to do cell merging till certain columns. It is working and the code is as follows.

Friend Shared Sub GridviewCellMerge(ByRef gridViewControl As GridView, ByVal colStart As Integer, _
                                            ByVal colLast As Integer)
            For rowIndex As Integer = gridViewControl.Rows.Count - 2 To 0 Step -1
                Dim gvRow As GridViewRow = gridViewControl.Rows(rowIndex)
                Dim gvPreviousRow As GridViewRow = gridViewControl.Rows(rowIndex + 1)
                For cellCount As Integer = colStart To colLast
                    If gvRow.Cells(cellCount).Text = gvPreviousRow.Cells(cellCount).Text Then
                        If gvPreviousRow.Cells(cellCount).RowSpan < 2 Then
                            gvRow.Cells(cellCount).RowSpan = 2
                            gvRow.Cells(cellCount).RowSpan = gvPreviousRow.Cells(cellCount).RowSpan + 1
                        End If
                        gvPreviousRow.Cells(cellCount).Visible = False
                    End If
        End Sub

1. a  b  c  d

2. a  b  c  e

3. a  b  f  e

4. a  b  f  e

5. a  b  g 

Accessing gridview cell values


Hi All,

In my application Iam using GridView, in this there are fields (Quantity, Price, Amount) the user can enter Quantity Field value which is a template field (textbox). Iam calculating Amount(Quantity * Price) using Javascript and assigning to the Amount Column cells as below

Gridviewcell.innerText=Quanity * price.

and when user clicks on the Save button I want to add these details of Gridview to the database.

when I try to access the values of the gridview using below code

For i=0 to GridView.rows.count-1

GridView.Rows(i).Cells(2).toString ( for Example)

Next i

It is not displaying the changed value instead it is displaying the default value before calculating the amount.

Before implementing the Javascript part, I had done this in the code behind and it was working fine... Now I just dont want the page to get load so I used javascript.

Can any one help me out in able to access the value of Gridview cells which are assigned using Javascript.



changing Asp.net Gridview's cell from Label to edit mode in code behined file


 Hi all,

In my asp.net application i'm using gridview to which i'm binding data dynamically by writing a select query in code behined file (all column's are autogenerated) now i want to change gridview cell to edit mode from label to textbox or dropdown on clicking of gridview's cell.How can i achive this in code behined file.

thanks in advance

How to make a cell editable in gridview?


I was trying to create a gridview which should allow to edit a perticular cell on clicking on it. But is not working as expected. Here is my code. Can anyone tell whats the issue with this.

<Window x:Class="Window1"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="279" Width="672">

        <Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}" >
            <Setter Property="Background" Value="#00ffffff" />
            <Setter Property="BorderBrush" Value="#00ffffff" />
            <Setter Property="Acce

Fill Gridview Based On Rights


I have a master table that will hold the information for publications for my company.  Not all of the publications can veiwed by all users.  What I am trying to figure out is how can I load all of the publications that the user is allowed to see into one grid view table.  For example: If Mary logs in she will only be able to see Accounts publications; if Sally logs in she can see General and Legal publications and if John logs in he can see IT, Legal and General publications.

I figured out how to do it with separate gridview tables on a page based on the roles.  I would make a gridview viewable if the user was in that role.  But I would really like to put all of this in one gridview if that is possible.  Does anyone have any ideas as to how I can do this?

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