Forms Data Controls :: Updating Dropdownlist Only In A Specific Cell In GridView

Mar 11, 2011

I have a situation where i need to update my Dropdownlist templatefield inside a GridView....but only for a specific cell. I have seen codes like this to loop through the whole GridView and update every rows in a specific column, but how do i do it if i only want to update one specific cell ? (If i know the index information of the cell, for example, I know i want to update the dropdownlist on Column 3 and Row 2)

foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
this.WorkTypeDDL = ((DropDownList)row.FindControl("WorkTypeList"));
this.WorkTypeDDL.DataSource = AL;
this.WorkTypeDDL.DataBind();
//more codes blah blah blah//
}
}

View 3 Replies


Similar Messages:

Forms Data Controls :: GridView Control Cell Turns Grey When Updating Cell?

Feb 11, 2010

I'm having a weird problem where the GridView cell that I'm programmatically updating turns grey, and throws a null error when attempting to save row. I have been searching all day and have not been able to find a solution. I'm guessing there is a problem with my code, so here it is:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

View 5 Replies

Forms Data Controls :: Updating A Cell In A Gridview

Sep 7, 2010

I have a gridview and I want to update a cell with a session variable username. In the Gridview1_RowEditing event I have this code :

GridView1.Rows(e.NewEditIndex).Cells(5).Text = Session("username")

It does not give me any errors and seems to work but the grid view cell do not take this session. When I'm clicking on the edit hyperlink this event is triggered.

View 5 Replies

Forms Data Controls :: Dynamically Add A Button With An Eventhandler To A Specific Cell In Gridview

Mar 10, 2010

I am banging my head with gridview at the moment. There's a problem I just can't get my head around. I'd be very greatful for any advice given. I have a function that creates a DataTable with three columns and four rows. In each of the cells I set the text to a random number through RowDataBound event. I would like to just make the cell clickable and have a code-behind function that gets the position of the cell (column, row) and the value of the cell when the user clicks it.

View 3 Replies

Forms Data Controls :: Retrieve A Text In Specific Cell Of Gridview On Onrowcreated Event?

Jun 9, 2010

I have a gridview which i bind to DataView. I need to manipulate text on cell[2] of each row. I was wondering if i could do it in the OnRowCreated event? cell[0] in asp looks like this

<asp:ButtonField DataTextField = "header" CommandName="select" HeaderText="Overskrift"/>

This doesnt work. test = null

protected void onrowcreated(object sender, GridViewRowEventArgs e)
{
TableCellCollection cells = e.Row.Cells;
string test = cells[2].Text;
}

View 2 Replies

Forms Data Controls :: Simulate The Gridview Function Of Updating Row Or Cell Data

Feb 13, 2010

I have an asp.net page with a gridview control on it but I want to allow the user to also be able to update the selected row from a series of textboxes. I simply need the code for a button click event to do this.

button is called button1
textbox is called textbox1
gridview control is named gridview1
record to be modified is in 3rd column called PlayerName

The row to be edited will always be the only record shown and will always be selected by code I've already written. I will also need to know if the record must be set to edit mode to make the button click code work.

View 7 Replies

Forms Data Controls :: Gridview Doesn't Sort On A Specific Column After Updating

May 10, 2010

I have been struggling with this problem for a long time. Does anyone have any clue about this problem? I created a gridview and set the allowsorting to true. This gridview has four columns: Name, Position, StartDate, and EndDate. I want the gridview to be sorted on the EndDate.

Inside of the save event, I called the BindGrid() function to rebind the datasource to the gridview. The changes will shown immediately, but the problem is that the records are not sorting on EndDate. I have to refresh the page manually to get the view sorted.

<asp:GridView ID="gvInfos" runat="server"
CheckBoxEnabled = "true"
ShowEmptyTable = "true"
AutoGenerateColumns = "False"
CssClass = "gv_white"
DataKeyNames = "Id"
GridLines = "None"
Width = "100%"
AllowSorting = "true"
>
<Columns>
<asp:ButtonField CommandName="Select" DataTextField="Name" HeaderText="Name" />
<asp:BoundField DataField="Position" HeaderText="Position" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date"
DataFormatString="{0:Y}" />
<asp:TemplateField HeaderText="End Date" SortExpression="EndDate">
<ItemTemplate>
<%# (((DateTime)Eval("EndDate")).Year == (DateTime.MaxValue.Year) || (DateTime)Eval("EndDate") == null) ? "Present" : ((DateTime)Eval("EndDate")).ToString("y")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

View 11 Replies

Forms Data Controls :: Make Specific Cells In A Dynamic Gridview Clickable And Capture The Cell Info Before Redirecting

Aug 3, 2010

I generate dynamic grids based on a count value returned from some DB tables. the code for it goes like this : I give and Id to each grid that is generated.

if (myDataList1.Count >= 1)
{
for (int i = 0; i < myDataList1.Count; i++)
{
//retrieving the exact i count from pageload
ViewState.Add("newCount", i);
//creating the dynamic grid with its corresponding gridview properties.
grvDynamic = new GridView();
grvDynamic.ID = "GridView" + (i+3);
grvDynamic.AutoGenerateColumns = false;
grvDynamic.RowCreated += GridViewRowCreated;
grvDynamic.RowDataBound += grvDynamic_RowDataBound;
//adding bound field columns to retrieve data from stored proc
BoundField metric = new BoundField();
metric.HeaderText = "Goal ";
metric.DataField = "metric";
grvDynamic.Columns.Add(metric);
BoundField mtd = new BoundField();
mtd.HeaderText = "MTD";
mtd.DataField = "value_MTD";
grvDynamic.Columns.Add(mtd);
BoundField goal = new BoundField();
goal.HeaderText = "Tier Level Achieved";
goal.DataField = "value_goal";
goal.HeaderStyle.Width = Unit.Percentage(10);
grvDynamic.Columns.Add(goal);
BoundField you1 = new BoundField();
you1.HeaderText = "Month End";
you1.DataField = "firstLevel_you";
grvDynamic.Columns.Add(you1);
BoundField you2 = new BoundField();
you2.HeaderText = "Month End";
you2.DataField = "secondLevel_you";
grvDynamic.Columns.Add(you2);
ButtonField singleClick = new ButtonField();
singleClick.CommandName = "clickHyperlink";
singleClick.Visible = false;
grvDynamic.Columns.Add(singleClick);
BoundField metricId = new BoundField();
metricId.HeaderText = "Metric Id";
metricId.DataField = "metricID";
metricId.Visible = true;
grvDynamic.Columns.Add(metricId);
//binding the gridview to data.
grvDynamic.DataSource = data;
grvDynamic.DataBind();
grvDynamic.Columns[5].Visible = false;
}
}

protected void grvDynamic_RowDataBound(object sender, GridViewRowEventArgs e)
{
//this basically gets the metric Id's of rows with the ishyperlink flag set to 'Y'. I need to make these particular cells clickable var isClickable = (from md in myDataList3 where md.IsHyperLinkFlag == 'Y' &&

md.value_MTD != null select md.metricID).ToList();
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Get reference to button field in the gridview.
LinkButton _singleClickButton = (LinkButton)e.Row.Cells[5].Controls[0];

if (isClickable.Contains(Convert.ToInt32(e.Row.Cells[6].Text)))
{
e.Row.Cells[1].Style["cursor"] = "hand";
e.Row.Cells[1].Style["color"] = "blue";
e.Row.Cells[1].Style["textdecoration"] = "Underline";
e.Row.Cells[1].Attributes.Add("onClick", "window.location ='../HeaderPages/page2.aspx' ");
}
}
}

This code works perfectly fine , depending on the ishyperlink flag in the database...specific cells in the grid are made clickable and then redirected to page2.aspx My Issue: I need to capture which specific cell in which specific grid the user has clicked. store some information in sessions based on the cell clicked and use that information in page2.aspx.

View 5 Replies

Forms Data Controls :: Modify Gridview Cell Value By Dropdownlist Inside

Feb 10, 2011

I have this question for a gridview that ai use for a shopping cart. On my first 4 collums is data from my database cart (the 4'th collumn contain the price), on the 5'th collumn is a dropdown list (having 1 to 30 values). what i want is when i change the value in dropdown list the 6'th collumn to be updated to the value of(dropdownlist value * price). on page_load i have this

GridView1.DataSource = clasa.my_chart_bike(Convert.ToInt16(Session["id"]));
GridView1.DataBind();
on GridView1_RowDataBound i have this
if (e.Row.RowType == DataControlRowType.DataRow)
{
string t=((DropDownList)e.Row.Cells[4].FindControl("DropDownList1")).SelectedValue;
e.Row.Cells[5].Text =Convert.ToString( Convert.ToInt16(t) * Convert.ToInt16(e.Row.Cells[12].Text));
}
GridView1.DataSource = clasa.my_chart_bike(Convert.ToInt16(Session["id"]));

View 4 Replies

Forms Data Controls :: Resources On Putting A Dropdownlist In A GridView Cell?

Feb 11, 2011

Im trying to find an example online where someone is manually coding a dropdownlist in a gridview.

View 10 Replies

Forms Data Controls :: Resources On Putting A Dropdownlist In A GridView Cell

Mar 21, 2011

<asp:Panel ID="PanelNew" runat="server">
<div>
<asp:GridView ID="GridViewTest2" runat="server" AutoGenerateColumns="true" AllowSorting="true" DataKeyNames="iOcsKeyToPropertyId"
onrowcancelingedit="GridViewTest2_RowCancelingEdit" onrowediting="GridViewTest2_RowEditing" onrowupdating="GridViewTest2_RowUpdating">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblColumnHeader" runat="server" Text="iocspropertyid"></asp:Label>
</HeaderTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownListTest" runat="server">
<asp:listitem>1 </asp:listitem>
<asp:listitem>2</asp:listitem>
<asp:listitem>Item 3</asp:listitem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</asp:Panel>

i have a stored Procedure that i want to replace the listItem 1,2,Item3. How can i replace that with the store procedure so i can see the info from my database in my DropDownList

View 3 Replies

Forms Data Controls :: Adding A DropdownList To A GridView On A Per Cell Basis

Apr 1, 2011

I am looking for a way to set certain cells in a GridView to have DropdownLists instead of the bound fields I currently use. I understand how people are able to do this on a whole column, but need to do this based on which cell it. Let me explain why. A fellow programmer who is as I am newer to ASP, built a GridView that only shows one record. This Record being the current ticket if you will. He builds a Data Table like this.

[Code]....

[Code]....

View 2 Replies

Forms Data Controls :: Updating Using Dropdownlist In GridView?

Feb 23, 2010

I was used TextBox in the GridView Then I Replace this textBox with Dropdownlist

and i fetched all the data from the database using DataSource in Editing Mode

But The problem is when i choose item from the dropdownlist to update it,it returns to Empty

(with No values) in the DropDownList??whats the problem?

[code]....

View 5 Replies

Forms Data Controls :: Updating A Row In A Gridview With A Dropdownlist

Oct 15, 2010

I have a gridview that holds 4 columns. in the fourth column there is a DropDownlist that holds three items.

I want my users to select one of the values and when they do the auto post back (which is set to true) should execute a method that updates the database selected row. But do i use the selectedindexchanged of the DDL or the Gridview? My head is totally thrashed so i imagine its really simple and im just over thinking it.

[Code]....

View 3 Replies

Forms Data Controls :: Updating A DropDownList In The GridView Using Databinding?

Mar 24, 2010

I am trying to create a Gridview in which I can update the Project Officer name in the Gridview from a DropDownList.

The Project Officer DDL comes from a seperate query (SqlProjectOfficerName) as the other information (SqlDataSource1)... as you can see below.

When I select EDIT, the DDL appears and I can select from the list of Project Officers, but when I select UPDATE, the name of the Project Officer doesnot change.

review the code below and assist as appropriate to write the Project Officer's name back to the table.

[Code]....

View 13 Replies

Forms Data Controls :: Updating Database Using Dropdownlist In Gridview

Nov 14, 2010

I have Gridview like that:

[Code]....

I bind data to GV in this way:

[Code]....

No problem with that. Now, I´d like to update the database with the dropdownlist in gridview, I wrote a method in this way:

[Code]....

The problem is when I click on the edit button there is nothing in the dropdownlist, it´s empty

View 6 Replies

Forms Data Controls :: Updating Gridview With Static Dropdownlist

Feb 10, 2010

I can't get my gridview to update? Inserting and deleting work fine. Here is my code:

[code]....

View 6 Replies

Forms Data Controls :: DropDownList Not Updating Inside Gridview

Mar 27, 2010

[Code]....

DropDownList not updating inside gridview

View 3 Replies

Forms Data Controls :: Get Specific Cell Of Datagrid?

Nov 16, 2010

I am using VS2003. How do I get specific cell of datagrid?

View 2 Replies

Data Controls :: Change Background Color Of GridView Cell Based On DropDownList Selected Value

Feb 15, 2014

I have a grid with 5 rows and 5 columns, All containing templetefield(Combobox)I am trying to set the background color of my grid cell(contain combobox) depending upon which item is selected. (again, dependent on item selection, so background color is not permanent). How can i achieve this?

View 1 Replies

Data Controls :: Update Row Cell Values In GridView On DropDownList Selected Index Changed

Jul 17, 2015

How do i change the name column text the current row when the selected index of drop down is changed? ex:first row is mudassar khan and belgium, when i change belgium i want mudassar to be replaced to a name which i fetch from database....

View 1 Replies

Forms Data Controls :: Gridview And Sql Bit - Check The Cell With The Bit Value To Change The Cell Color

Apr 30, 2010

I have a grid view populated with some data included bit fields and I made an export to excel function For each row i need to check the cell with the bit value to change the cell color, but the cell is always empty, even if is the field is set to False or True. foreach (GridViewRow row in gv.Rows)

View 2 Replies

Web Forms :: DropDownList And Gridview For Updating Data / How To Get The Text Not The Value

May 3, 2010

i have a DropDownlist in my GridView that is bind to another DataSource than the GridView.

For the display it is working well but when I want to update datas I m stuck. Something is wrong and I don't know why.

[Code]....

I am stocking in the Database the value of the dsDroit but when I want to update the field I just know how to get the text not the value.

View 9 Replies

Web Forms :: Hide Specific Row Cell From GridView Based On Some Condition

Aug 3, 2012

I have a gridview which displays a list of submittted applications with a column that contains an edit link.

<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEdit" runat="server" CommandArgument = '<%# Eval("appID")%>' Text = "Edit" OnClick = "editApp" />
</ItemTemplate>
</asp:TemplateField>

I want to hide the link button if the status (value 1 or 0) of the form is set to 1. Here is the code I am trying to use.

Protected Sub gv1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'get the cell cell value
Dim status As Integer

[code]....

I think my mistake lies in getting the status value (as it ouputs 0 for every application).

View 1 Replies

How To Use GridView To Select Specific Cell

Oct 22, 2010

I'm developing an management staff calendar and i'm having some problem with the gridview manipulation. (.net C# web-application)What i want it's to select a specific day for a staff employee and then see wich project is he working on day1-Month-Year

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved