Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Forms Data Controls :: GridView Event RowUpdating / RowUpdated?


[Code]....


View 2 Replies (Posted: Mar 26, 2010 10:39 PM)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Forms Data Controls :: Getting New Value In Gridview RowUpdating Event
I have the following code below in my GridView1_RowUpdating event.

myTextBox = ((TextBox)(GridView1.Rows[GridView1.EditIndex]).Cells[7].Controls[0]);
unitsInStock = Convert.ToInt16(myTextBox.Text);

Unfortunately, it looks like I'm getting the value prior to the edit. How can I get the new value?

Posted: Jul 28, 2006 05:33 PM

View 9 Replies!   View Related
Forms Data Controls :: Use Nested Gridview's Rowupdating Event?
I have a GridView within a GridView. I want o access child gridview's rowupdating event. i want to update row.

this is my GridView's code as follows

[Code]....

Posted: Aug 31, 2010 09:18 AM

View 6 Replies!   View Related
Forms Data Controls :: GridView RowUpdating Event Implementation?
I have been working with the DataGrids and recently have been trying to implement the.NET 2.0 GridView control. I am stuck at certain implementations. I do not know how to implement the RowUpdating event in the GridView. If it was a DataGrid, I would haveused the code below and made the updating of the DataGrid work. However, now I am all confused and lost with the GridView. What is the equivalent of e.Item.Cells[] when usingGridViewUpdateEventArgs. As you can see I am not using the DataSource control and am binding my DataGrid in this method. I want to do the same thing in Gridview.

protected void DataGrid1_UpdateCommand(object source,
DataGridCommandEventArgs e)
{

[code]...

Posted: Jan 03, 2007 05:05 PM

View 6 Replies!   View Related
Forms Data Controls :: Unable To Update Row Using Gridview Rowupdating Event
I am trying to update the row using gridview_rowupdating event but I am unable to update. I tried the code like this...

foreach (GridViewRow i in GridView1.Rows)
{
TextBox sname = i.FindControl("sname") as TextBox;
TextBox fname = i.FindControl("fname") as TextBox;
TextBox sex = i.FindControl("txtsex") as TextBox;
// Label lblpin1 = i.FindControl("lblpin") as Label;
TextBox tpin = i.FindControl("txtpin") as TextBox;
tpin.Enabled = true;
// lblpin1.Enabled = true;
string pinno;
pinno = Convert.ToString(tpin.Text.Trim());
conn2.Open();
SqlCommand cmd = new SqlCommand("update NRDetails2010 set SNAME='" + sname + "',FNAME='" + fname + "',SEX='" + sex + "' where pin='" + pinno.Trim() + "' and InstCode='" + Session["UId"] + "' and Sem='" + ddlsem.SelectedItem.Text + "' and scheme='"
+ ddlscheme.SelectedItem.Text.Trim() + "' ", conn2);
cmd.ExecuteNonQuery();
conn2.Close();
}

I am getting error at cmd.ExecuteNonQuery()

Here I am giving connection globally and opening in this event. In gridview, I am updating 3 fields depending on 4 conditions.

Posted: Jun 17, 2010 06:14 AM

View 3 Replies!   View Related
Forms Data Controls :: Updating Field Value In Gridview Rowupdating Event
I have a Modified Date and Modified By column in my gridview and I wantthem to be updated with the current date and current user any time a user updates the row.

I converted my columns totemplate fields and the textboxes in the edititemtemplateare bound to my sql data columns "ModifiedDate" and "ModifiedBy"

Then I added the attached code in my RowUpdating event.

When I test the code and click the Update link on my gridview I don't get an error but the values don't update either. I put a breakpoint on the code and when I hover over "ModifiedDateLabel.Text" I see the old value of the field so I know I'm accessing the control correctly.

Posted: Mar 15, 2010 03:35 PM

View 3 Replies!   View Related
Forms Data Controls :: Dynamic GridView RowUpdating Event Handler Will Not Run?
I'm creating a GridView in code. I can successfully attach handlers for Editing, and CancelEditing. RowUpdating never runs, however. Instead, if the GridView is in a Panel, the Edit handler is called when Update is clicked (and this is the command name I get back on the Update click, too). If the GridView is not in a panel, then the Cancel handler is called when Update is clicked (again, this is the command name I get back from clicking Update). I've searched high and low for a reason why the RowUpdating event is not getting called, and I can't find one. Does anyone out there haveHere is my code (My actual code is much more involved than this, but for testing purposes, I extracted the following code and stuck it in a new project to isolate my problem):

protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)

[code]...

Posted: Feb 01, 2010 07:44 PM

View 1 Replies!   View Related
Forms Data Controls :: RowUpdating Event Not Firing On Update Button Click For GridView Control?
I've viewed some of the other posts and although they come close to addressing my problem they still leave something lacking so here goes.The GridView control resides in a User Control which is referenced in an .aspx page that is housed inside a Master Page.the View state is disabled because I need the the Grid View to be displayed even when there is no data. I bind the data on each postback which I think might be part of the problem. However the cancel button still fires the event.

One thing I did notice is that is that when the update button is clicked not even the RowCommand event is fired, which I thought was strange.Also, the data source is a SubSonic table class that is stored in Session (If you don't know SubSonic is just a little provider that maps tables into classes so you can object oriented version of you tables that intellisense will recognize, a pretty nifty tool).I hope I'm specific enough and if you need some more information please let me know.

Posted: Feb 09, 2007 09:50 PM

View 10 Replies!   View Related
Forms Data Controls :: Gridview Rowupdating Event Shows Error "Input String Was Not In A Correct Format?
this is my gridview rowupdating event shows error "Input string was not in a correct format. " , I am very near to my result but this error comes I really dont know why

this is my code...

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["contest"].ConnectionString);
con.Open();

[Code]....

Posted: Nov 23, 2009 06:01 AM

View 21 Replies!   View Related
Forms Data Controls :: Gridview Rowupdated Not Working?
After i click edit, i will get Update and Cancel buttonWhen I viewsource, I get this

<input type="submit" name="GridView1$ctl07$ctl01" value="Update"
onclick="javascript:WebForm_DoPostBackWithOptions( new
WebForm_PostBackOptions("GridView1$ctl07$ctl0 1",

[code]...

Posted: Sep 03, 2010 12:03 PM

View 2 Replies!   View Related
Forms Data Controls :: Difference In Gridview RowUpadting & RowUpdated Events?
I want to know thatinany data controls like gridview or form view or details view there is two events

1. GridView1_RowUpdating()
2.GridView1_RowUpdated()

What the difference between them and which is better ?

Posted: May 22, 2010 04:21 AM

View 2 Replies!   View Related
C# - Cells In Gridview Lose Controls On RowUpdating Event?
I'm using a GridView to display some columns and rows that reside in a database. This works excellent. Because i wanted to add columns dynamically out of a List of names. Let's say we have a list with 5 names in it, then it dynamically creates a column for every name in the GridView.

Here's some code to display what i do:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Create columns for each student
List<Student> allStudents = new Eetlijst.Business.Students().GetAll();
allStudents.Reverse();.......

How do i create the dynamic columns for each row? I create them with a DataBound event. So when the GridView databinds, the columns get filled with data. There is also a check inside to see if the row is in edit mode or not. So when i click on the edit button next to the row, the row goes perfectly in edit mode. The code i made adds a TextBox control to the cell.

When i fill in a value and press the Update button, it can't find any controls anymore and therefore i can't get the value i entered. The control is still there in the DataBound when i put a break point after it. But as soon as i click the Update button, all the controls of the cells are gone.

I searched on the internet and all i found is that it has something to do with the application firing a postback before it reaches the RowUpdating method.

So, how can i let the controls exist that i added to the cell when it is in edit mode?

Posted: Jan 6 10 at 10:11

View 2 Replies!   View Related
Forms Data Controls :: How To Get Data Key Of The GridView Row After Updating (in RowUpdated Method)
I have a requirement something as below.

1. I will click on the EDIT link in one of the grid view row. The row will change to edit mode

2. I will update the values and click update link in edit mode and edit mode closes.

3. At this point I need to capture the datakey of the updated row into some variable

Posted: Jan 05, 2011 12:38 PM

View 3 Replies!   View Related
Forms Data Controls :: RowUpdating Event - Unable To Update Row
I am using a gridview and want to update the row.. but i am unable to do it.... pls help me out where i am going wrong.... here is the code for the gridview nd rowupdating event.

<asp:GridView ID="GridView1" runat="server" Width="514px" AllowPaging="True"

Posted: Dec 13, 2010 12:53 PM

View 1 Replies!   View Related
Forms Data Controls :: Can't Find New Values In RowUpdating Event
I have a simple gridview with two boundfields (CustomerID and CustomerName). I am not using a sqldatasource, instead I have a List of Customers that I bind to the gridview. I want to be able to update the Customers names. I have set the AutoGenerateEditButton="True". If I click the edit button I go into edit mode. When I click Update button, I want to read the updated values and send them to a stored procedure. My problem is that I can't find the new values in theRowUpdating event. The new values in the Dictionary e.NewValues

protected void grdCommissionGroup_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
{
foreach (System.Collections.DictionaryEntry entry in e.NewValues)
{
//Some code goes here
}
grdCommissionGroups.EditIndex = -1;
BindData();
}

I could solve this by not using boundfields, but I want to know how to use the boundfields correctly when updating.

Posted: Sep 23, 2009 01:11 PM

View 2 Replies!   View Related
Forms Data Controls :: Breaking At Spot Below In Rowupdating Event
It's breaking at spot below in RowUpdating Event with the error msg "Index was out of range. Must be non-negative and less than the size of the collection"

txtAddress = CType(GridView1.Rows(e.RowIndex).FindControl("txtAddress"), TextBox).Text
Here's my code:
ASP
<form id="form1" runat="server">
<asp:GridView id="GridView1" runat="server" CssClass="Grid" DataKeyNames="ID"
AllowPaging="false"
OnRowEditing = "GridView1_RowEditing" OnRowDeleting = "GridView1_RowDelete"
OnRowUpdating = "GridView1_RowUpdating"
AutoGenerateColumns="False"
EnableViewState="false" ShowFooter="true">
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<%#Eval("ID")%>
</ItemTemplate>
<FooterTemplate>
<asp:Button id="btnAdd" Runat="server" Text="Add New" CommandName="Insert"></asp:Button>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="true" EditText="Edit" HeaderText="Edit" CausesValidation="false"/>
<asp:CommandField ShowDeleteButton="true" EditText="Delete" HeaderText="Delete />
<asp:TemplateField HeaderText="mlsnum">
<EditItemTemplate>
<asp:TextBox ID="txtMls" runat="server" Text='<%# Eval("mlsnum") %>'/>
</EditItemTemplate>
<ItemTemplate>
<%#Eval("mlsnum")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtMLS" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqMLS"
runat="server" ControlToValidate="txtMLS"
Display="Dynamic"
ErrorMessage="You must enter an MLS #.">
* </asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<EditItemTemplate>
<asp:TextBox ID="txtAddress" runat="server" Text='<%# Eval("Address") %>'/>
</EditItemTemplate>
<ItemTemplate>
<%#Eval("Address")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqAddress"
runat="server" ControlToValidate="txtAddress"
Display="Dynamic"
ErrorMessage="Please enter an address.">
* </asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subdivision">
<EditItemTemplate>
<asp:TextBox ID="txtSubdivision" runat="server" Text='<%# Eval("subdivision") %>'/>
</EditItemTemplate>
<ItemTemplate>
<%#Eval("Subdivision")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSubdivision" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqSubdivision"
runat="server" ControlToValidate="txtSubdivision"
Display="Dynamic"
ErrorMessage="Please enter a Subdivision.">
* </asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price">
<EditItemTemplate>
<asp:TextBox ID="txtPrice" runat="server" Text='<%# Bind("Price") %>'/>
</EditItemTemplate>
<ItemTemplate>
<%#Eval("Price")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqPrice"
runat="server" ControlToValidate="txtPrice"
Display="Dynamic"
ErrorMessage="Please enter an Price.">
* </asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Agent">
<ItemTemplate>
<%#Eval("Agent")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAgent" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqAgent"
runat="server" ControlToValidate="txtAgent"
Display="Dynamic"
ErrorMessage="Please enter an Agent.">
* </asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comment">
<EditItemTemplate>
<asp:TextBox ID="txtComment" runat="server" Text='<%# Eval("Comment") %>'/>
</EditItemTemplate>
<ItemTemplate>
<%#Eval("Comment")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtComment" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqComment"
runat="server" ControlToValidate="txtComment"
Display="Dynamic"
ErrorMessage="Please enter a Comment.">
* </asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PhotoAd">
<EditItemTemplate>
<asp:checkbox ID="chkPhotoAd" runat="server" Checked=true/>
</EditItemTemplate>
<ItemTemplate>
<asp:checkbox id="chkPhotoAd" runat="server" Enabled="true" />
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="chkAddPhotoAd" runat="server" Enabled="true" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LineAd">
<EditItemTemplate>
<asp:checkbox ID="chkLineAd" runat="server" Checked=true/>
</EditItemTemplate>
<ItemTemplate>
<asp:checkbox id="chkLineAd" runat="server" Enabled="true" />
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="chkAddLineAd" runat="server" Enabled="true" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="# of Balloons">
<EditItemTemplate>
<asp:TextBox ID="txtNumBalloons" runat="server" Text='<%# Eval("NumBalloons") %>'/>
</EditItemTemplate>
<ItemTemplate>
<%# Eval("NumBalloons")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="intNumBalloons" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Try
BindData()
Catch ex As Exception
'Error Handler
lblError.Visible = True
lblError.Text = Err.Description()
'lblError.Text = Err.Number
End Try
End If
End Sub
Sub BindData()
Dim ds As New DataSet
Dim objDS = New DataSet
Dim cmd As SqlCommand
Dim dataAdapter As New SqlDataAdapter
strSqlConnection = ConfigurationManager.AppSettings("ConnectionString")
sqlConn = New SqlConnection(strSqlConnection)
strSqlStatement = "select * from tblAdSignup"
cmd = New SqlCommand(strSqlStatement, sqlConn)
dataAdapter.SelectCommand = cmd
dataAdapter.Fill(ds)
objDS.DataSetName = "ds"
GridView1.DataSource = ds
GridView1.DataBind()
End Sub
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
GridView1.ShowFooter = False
GridView1.EditIndex = e.NewEditIndex
BindData()
End Sub
Protected Sub GridView1_RowCancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
GridView1.ShowFooter = True
GridView1.EditIndex = -1
BindData()
End Sub
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
'Try
'BindData()
'Dim eRow As Int16 = e.RowIndex
'Dim id2 As Integer
ID = GridView1.DataKeys(e.RowIndex).Value
'ID2 = GridView1.DataKeys(1).Value
Dim txtAddress, txtAddress2 As String
'Dim test As Integer
'test = GridView1.Rows(0).Cells.Count
'Dim strAddress As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtAddress"), TextBox).Text
'Dim txtAddress As TextBox
'txtAddress = DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtAddress"), TextBox)
txtAddress = CType(GridView1.Rows(e.RowIndex).FindControl("txtAddress"), TextBox).Text
'txtAddress2 = GridView1.Rows(0).Cells(0).Text
'txtAddress2 = CType(GridView1.SelectedRow.FindControl("txtAddress"), TextBox).Text
'
'Catch ex As Exception
' 'Error Handler
' lblError.Visible = True
' lblError.Text = Err.Description()
' 'lblError.Text = Err.Number
'End Try
End Sub

Posted: May 20, 2010 03:14 PM

View 8 Replies!   View Related
Forms Data Controls :: Update Value Of A Templated Field In The RowUpdating Event?
How can i update value of a templated field in the RowUpdating event?

Posted: Nov 03, 2009 12:56 PM

View 4 Replies!   View Related
Forms Data Controls :: Getting Old Values From Gridview On Rowupdating
i am getting old values in the rowupdation in gridview , while clicking over the update button , in my code behind i am using below code to get value.

Dim gvr As GridViewRow = qview.Rows(e.RowIndex) Dim txtqty As TextBox = gvr.FindControl("txtqty") Dim txtdescription As TextBox = gvr.FindControl("txtdescription") Dim txtunit_price As TextBox = gvr.FindControl("txtunit_price") 'Reset the edit index. qview.EditIndex = -1 'Bind data to the GridView control. dispqsummary(1) Response.Write(txtqty.Text) Response.Write(txtdescription.Text)
Response.Write(txtunit_price.Text)

but i am getting all the old values stored in the gridview when the grid was loaded.

Posted: Jul 20, 2009 09:39 AM

View 4 Replies!   View Related
Forms Data Controls :: GridView - RowUpdating Not Firing
I've put a simple gridview on my Asp.net webpage. I've configured the fields via C# code:

gvMainDataGrid.AutoGenerateColumns = false;
gvMainDataGrid.AutoGenerateDeleteButton = false;
BoundField bfldSeqNmbr = new BoundField();
bfldSeqNmbr.DataField = "PKSequenceNmbr";
bfldSeqNmbr.Visible = false;
gvMainDataGrid.Columns.Add(bfldSeqNmbr);
BoundField bfldEmployeeCode = new BoundField();
bfldEmployeeCode.DataField = "Employee Code";
bfldEmployeeCode.HeaderText = "Employee Code";
gvMainDataGrid.Columns.Add(bfldEmployeeCode);
BoundField bfldProjectCode = new BoundField();
bfldProjectCode.DataField = "Project Code";
bfldProjectCode.HeaderText = "Project Code";
gvMainDataGrid.Columns.Add(bfldProjectCode);
BoundField bfldProcessCode = new BoundField();
bfldProcessCode.DataField = "Process Code";
bfldProcessCode.HeaderText = "Process Code";
gvMainDataGrid.Columns.Add(bfldProcessCode);
BoundField bfldActivityDate = new BoundField();
bfldActivityDate.DataField = "Date";
bfldActivityDate.HeaderText = "Date";
gvMainDataGrid.Columns.Add(bfldActivityDate);
BoundField bfldActivityHours = new BoundField();
bfldActivityHours.DataField = "Activity Hours";
bfldActivityHours.HeaderText = "Activity Hours";
gvMainDataGrid.Columns.Add(bfldActivityHours);
CommandField cfldDeleteButton = new CommandField();
cfldDeleteButton.ShowDeleteButton = true;
gvMainDataGrid.Columns.Add(cfldDeleteButton);
It's data source is a Dataset retrieved from a webservice. Here is the C#code to bind the data to the gridview
Service1 MyService = new Service1();
dsMainData = MyService.GetData(strIdNumber);
gvMainDataGrid.DataSource = dsMainData;
gvMainDataGrid.DataBind();

It retrieves great. No problems at all. Then, when I actually try to use the delete button, I get an error that the RowDeleting event is not being handled. I thought that was pretty explicit, so I created the event:

private void gvMainDataGrid_RowDeleting(Object sender, GridViewDeletedEventArgs e)
{
return;
}

Well.....that didn't work. So, I thought that maybe I needed to configure it via the actual aspx file. So, I changed

<asp:GridView ID="gvMainDataGrid" runat="server">
</asp:GridView>
to this:
<asp:GridView ID="gvMainDataGrid" runat="server" ondeleting="gvMainDataGrid_RowDeleting">
</asp:GridView>

But, no avail. I've scoured the web and tried so many combinations of capital letters and whatnot -- but no effect.

Posted: Apr 01, 2010 12:57 AM

View 3 Replies!   View Related
Forms Data Controls :: Gridview Rowupdating Contains Old Values
Here is thecode with the issue:

[Code]....

The value of txtName, for example, contains the value prior to editing and clicking update. Here is the grid code:

[Code]....

Posted: Jul 13, 2010 03:28 AM

View 17 Replies!   View Related
Get Old Gridview Row Values In The RowUpdating Event
How do I get the old values in a gridview row in the row_updating event? I'm using a sqldatasource control to populate the grid and want to write the update code in the RowUpdating event. There are 10 fields displayed in the grid. I can get the value of the first field using string old_Category = e.OldValues[0].ToString();.

But it doesn't work for index items greater than 0. This doesn't work string old_Category = e.OldValues[1].ToString(); it returns an error message Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index. even though there are 10 columns in the grid.

<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1"
BorderWidth="0px"
BorderStyle="None"
Width="100%"
CellPadding="2"
PageSize="25"
OnRowDeleting="ProjectListGridView_RowDeleting"
onrowdatabound="GridView1_RowDataBound"
onrowupdating="GridView1_RowUpdating" onrowediting="GridView1_RowEditing" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="WeekEnding" SortExpression="WeekEnding">
<ItemTemplate>
<asp:Label ID="lblWeekEnding" runat="server" Text='<%# Bind("WeekEnding") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Project" SortExpression="Project">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList1"
runat="server"
DataSourceID="sdsDdlProjectsEdit"
DataTextField="ProjectName"
DataValueField="ProjectID"
AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"
>
</asp:DropDownList>
<asp:SqlDataSource
ID="sdsDdlProjectsEdit"
runat="server"
ConnectionString="<%$ ConnectionStrings:ttuser %>"
SelectCommand="SELECT ProjectID,ProjectName FROM dbo.aspnet_starterkits_Projects">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Project") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="Category">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList2"
runat="server"
DataSourceID="sdsDDL2"
DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
<asp:SqlDataSource
runat="server"
ID="sdsDDL2"
ConnectionString="<%$ ConnectionStrings:ttuser %>"
SelectCommand="SELECT [CategoryID], [CategoryName],[ProjectID] FROM dbo.aspnet_starterkits_ProjectCategories WHERE ([ProjectID]=@ProjectID)">
<SelectParameters>
<asp:Parameter Name="ProjectID" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Category") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sun" SortExpression="Sun">
<EditItemTemplate>
<asp:TextBox ID="txtSunEdit" runat="server" Text='<%# Eval("Sun") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblSun" runat="server" Text='<%# Bind("Sun") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mon" SortExpression="Mon">
<EditItemTemplate>
<asp:TextBox ID="txtMonEdit" runat="server" Text='<%# Eval("Mon") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Mon") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tue" SortExpression="Tue">
<EditItemTemplate>
<asp:TextBox ID="txtTueEdit" runat="server" Text='<%# Eval("Tue") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Tue") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Wed" SortExpression="Wed">
<EditItemTemplate>
<asp:TextBox ID="txtWedEdit" runat="server" Text='<%# Eval("Wed") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Wed") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Thu" SortExpression="Thu">
<EditItemTemplate>
<asp:TextBox ID="txtThuEdit" runat="server" Text='<%# Eval("Thu") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Thu") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fri" SortExpression="Fri">
<EditItemTemplate>
<asp:TextBox ID="txtFriEdit" runat="server" Text='<%# Eval("Fri") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Fri") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sat" SortExpression="Sat">
<EditItemTemplate>
<asp:TextBox ID="txtSatEdit" runat="server" Text='<%# Eval("Sat") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Sat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and here is the sqldatasource
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ttuser %>"
SelectCommand="SELECT
@WeekEnding WeekEnding
,Project
,ProjectID
,Category
,CategoryID
,isnull([1], 0) Sun
,isnull([2], 0) Mon
,isnull([3], 0) Tue
,isnull([4], 0) Wed
,isnull([5], 0) Thu
,isnull([6], 0) Fri
,isnull([7], 0) Sat
from
(select P.ProjectName Project,P.ProjectID, CAT.CategoryName Category,CAT.CategoryID, Datepart(dw, TE.TimeEntryDate) DOW, TE.TimeEntryDuration Hours
FROM
dbo.aspnet_starterkits_TimeEntry TE inner join
dbo.aspnet_starterkits_ProjectCategories CAT on
TE.CategoryID=CAT.CategoryID inner join
dbo.aspnet_starterkits_Projects P on
CAT.ProjectID=P.ProjectID
Where (TE.TimeEntryDate between dateadd(dd, -6, @WeekEnding) and @WeekEnding) AND
TE.TimeEntryUserID=(SELECT UserId FROM dbo.aspnet_Users WHERE UserName=@UserName)) Source
pivot (max(Hours)for DOW in ([1],[2],[3],[4],[5],[6],[7]) ) as pvt" OldValuesParameterFormatString="original_{0}"
<SelectParameters>
<asp:ControlParameter ControlID="WeekEnding2" Name="WeekEnding"
PropertyName="Text" />
<asp:ControlParameter ControlID="UserList" Name="UserName"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>

Posted: Aug 25 10 at 21:02

View 1 Replies!   View Related
Forms Data Controls :: GridView RowUpdating - Unable To Get New Values
I have a GridView on my page and I have bound a custom DataSource (DataTable populated from an SQL query) within an UpdatePanel. I have set the OnRowUpdating property and create the code behind stuff as well as setting AutoGenerateEditButton to true. The problem I have is that when I click on 'Edit', then change some values then click 'Update', I can only get the old values.

.ASPX

[Code]....

All of the other posts I have read have mentioned the GridView being bound on post back or within a RowDataBound event but I'm pretty sure that I am not doing that.The RowUpdating event does fire but the value of Jockey, for example, is still the original.

Posted: Apr 23, 2010 06:02 PM

View 3 Replies!   View Related
Forms Data Controls :: Dynamic Gridview Is Empty On RowUpdating?
[Code]....

Dynamic Gridview is Empty on RowUpdating

Posted: Mar 18, 2010 03:25 PM

View 9 Replies!   View Related
Forms Data Controls :: GridView Rowupdating Returns Old Values?
my gridview row updating events return old values.. edititem templatefield gets its old value on row updation.

My code is as follows :-

[Code]....

Posted: Sep 24, 2010 09:01 AM

View 5 Replies!   View Related
Forms Data Controls :: ENewValues Not Working With RowUpdating On GridView?
I have a GridView ona "View Order" page which pulls data from a table: an item name, its description, the quantity ordered, the unit price and the total (item) cost: unit price * quantity ordered. This data, including the calculation for total cost is handled on the previous "Place Order" pageusing a Stored Procedure.

I want the user on the "View Order" page to be able to hit the standard "Edit" link (Command Field over at the left) and then change the "Quantity" field. This works fine and, when "Update" is hit, the field reflects the change.

PROBLEM: Because the Total Cost is calculated on the previous page, thsi doesn't change, I need to calculate it again.

WHAT I'VE TRIED: I've stripped the TotalCost field out of the SqlDataSource Update commands and attempted to use e.NewValues in the RowUpdating event handler to inject the new calculation. This doesn't work.

WHAT HAPPENS: The "ViewOrder" page refreshes, the new quantity is there but the TotalCost has not changed. No errors reported.

Is this the right way to do it and, if so, is my code okay? Here it is:

ASPX for ViewOrder:

[Code]....

And here's the Code Behind for ViewOrder:

[Code]....

"OrderMealValue" is the field for the Total Cost.

The fourth colum contains the Quantity and the fifth the price for one item.

Posted: Nov 25, 2010 11:14 AM

View 2 Replies!   View Related
Forms Data Controls :: DropDownList Disappears From Gridview On RowUpdating?
I am populating acolumn in a gridview with a dropdownlist as follows:

[Code]....
[Code]....

When Iedit the gridrow, the dropdown is there and I can select a new item.

But I can't find the dropdown during the rowupdated event.Thecell control says it's a Textbox. All of the other items in the row are fine and I can get thedata back. But I can't get theDropDown item.

Here are some of the things I have tried in the RowUpdating event:

DropDownList test = (DropDownList)e.FindControl("ddlPeriod");
//null
DropDownList ddl = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlPeriod");
//Also null
var test = row.Cells[8].Controls[0];
//Says its a textbox.

Posted: Jan 21, 2011 05:42 PM

View 5 Replies!   View Related
Forms Data Controls :: E.Cancel In GridView:RowUpdating() Does Not Work?
I have a GridView. I allow editing using:

[Code]....

As I allow editing of row, so I have GridView:RowUpdating(). In it, I check if the entered value is valid. If not, I have e.Cancel = true.

[Code]....

After I see the message box comes up, the textbox still stays the same. I expect the textbox will disappear just as if I have pressed the Cancel button. (By the way, the ClientUtil is a class someone has written for me.)

How do I make the e.Cancel = true works as if I press the Cancel button.

Posted: Mar 03, 2010 11:25 AM

View 2 Replies!   View Related
Forms Data Controls :: Gridview Rowupdating Throws Index Out Of Range
The table serving as the data source is a simple access table.

[Code]....

Posted: Dec 17, 2010 04:58 PM

View 7 Replies!   View Related
Forms Data Controls :: Unable To Get Changes Made To Rows In Gridview RowUpdating
Given this .aspx :

[Code]....

and this piece of code in code-behind:

[Code]....

why am I not able to get the updated changes ? I keep on getting the old values.

Posted: Dec 14, 2009 01:39 PM

View 3 Replies!   View Related
Custom Server Controls :: GridView RowUpdating Event Not Firing In Custom Composite Control
Everything works as advertised but for the life of me I can't get the RowUpdating vent to fire. When you click the Update or Cancel buttons the RowCommand event fires but the e.CommandName for both is Select and never Update. The AddHandler dg.RowUpdating, AddressOf dg_RowUpdating never fires at all. Hopefully someone will have a soulution.

Public Class PollAdmin
Inherits CompositeControl
Implements INamingContainer
Dim sql As New SQLCrud
Public Event QuestionSubmitted As System.EventHandler
[code]...

Posted: Oct 01, 2009 11:04 PM

View 4 Replies!   View Related
Forms Data Controls :: Update Database By Using Checkboxlist In Edit Template Field In Gridview Rowupdating
Ihave a checkboxlist in a template field in a gridview and when in edit mode, im trying to gather what the user has selected, builda string from it, and then set an UpdateParameter to it and update the database.

I am trying like below, but I keep getting an Object Reference Not SetTo Instance of Object error.

[Code]....

Posted: Dec 09, 2009 04:36 AM

View 3 Replies!   View Related
Forms Data Controls :: Find Row Index (or ID) In RowUpdated() ?
Seems I can't find a way to get row index (or id) for the row just updated in gridview1_RowUpdated()

(in RowUpdating, I can use: for example:

txtActivityID = CType(gridview1.Rows(e.RowIndex).FindControl("txtActivityID"), TextBox)

)

Posted: Sep 23, 2010 06:25 PM

View 1 Replies!   View Related
DataSource Controls :: Gridview Updating The Old Values On RowUpdating?
I have a gridview that I'm trying to update the Date something is corrected in the database. When I am putting a new value in, it is updating, but it isn't updating the new value, just the old one that is already there. I cannot figure out why this is happening.

[Code]....

Posted: May 11, 2010 03:23 PM

View 8 Replies!   View Related
Forms Data Controls :: Get Datakeyfield ID In Ghridview Rowupdating?
How to get the id of the row in gridview, DataKeyField="OrderID"

Protected Sub dgdOrders_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles dgdOrders.RowUpdating
end sub

Posted: Apr 02, 2010 01:18 AM

View 2 Replies!   View Related
Forms Data Controls :: Gridview RowDataBound Event Fires On Every Command Event?
why the gridview RowDataBound event fires during a select command. I only expect it to run when the gridview is being populated with data. Is there some way to stop it from runningwhen the select command is triggered?

Posted: Jul 19, 2010 08:53 PM

View 3 Replies!   View Related
Forms Data Controls :: Textbox Changed Event In The Gridview Takes A Lot Of Time To Fire The Event Handler
I have a dynamic gridview where the Columns are added dynamically...

This has 100 columns and 100 rows. where in i have a static column which has a textbox control.

[Code]....

to fire this event OnTextChanged="txtMultiplier_OnTextChanged"

its taking more than 15 seconds which makes my application slow. Is there any better way to fire the event..

Posted: Oct 05, 2009 01:47 PM

View 6 Replies!   View Related
Forms Data Controls :: Access Controls Inside Gridview When An Event Outside Gridview Fires?
I have a dropdownlist outside the gridview control. My griview control also have dropdownlist in the first column. I want to populate the dropdownlist inside the gridview control for all rows when the selected item is changed in the outside dropdownlist.

Posted: Jan 10, 2010 09:54 PM

View 2 Replies!   View Related
Forms Data Controls :: How To Show Textbox Outside The Gridview On Gridview Button Click Event
I have a button in gridview

And I have a textbox outside the gridview with visible property="False"

Now I want to set the textbox Visible Property="True" on Gridview button click event

Posted: Oct 13, 2009 08:20 PM

View 3 Replies!   View Related
Forms Data Controls :: Dynamically Accessing Label In GridView TemplateField During GridView RowDataBound Event?
I have a Label control inside GridView TemplateField.

How can I access it dynamically in GridView RowDataBound event. Can you provide VB code since I'm using VB?

Posted: Mar 01, 2008 09:00 PM

View 5 Replies!   View Related
Gridview.RowUpdating , Row Cell Value By Cellname
I am just wondering how to access the cell value for the row updating (event = Gridview.RowUpdating)

SqlDataSourceLocations.UpdateParameters("LocationName").DefaultValue = GridViewLocations.Rows.Item(e.RowIndex).Cells("LocationName").ToString
Message="Conversion from string "LocationName" to type 'Integer' is not valid."

I would prefer to get the cells by name rather then by location e.g. 0,1,2,... since the location might change.

PS: location name is not an integer

Posted: Dec 06, 2008 06:29 PM

View 9 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved