.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 do I keep the previous GridView field value and then concatenate new ones?

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
Hello all, I have a Timer and a GridView who pulls info from the database every X seconds.Every time I query the database the field 'Comments' is replaced with whatever is on the database  (since it's bound to it).I'd like to keep my previous value and keep adding into my Label the subsequent values queried from the database. For instance, first time I query I get a value of "1" in the Gridview. Now someone changes the database row and next time I queryit I have a value of "2". Well, I would like to concatenate the last value queried with the previous one and so on. So at this point the GridView should show "1" and "2". Here is the piece of code I am talking about: <asp:TemplateField HeaderText="Comments" SortExpression="Comments"> <ItemTemplate>  <asp:Label ID="lblComments" runat="server" Text='<%# Bind("Comments") %>' /> </ItemTemplate></asp:TemplateField> How do I achieve this goal? Thank you!

View Complete Post

More Related Resource Links

Gridview hyperlink field

Hi I have a gridview that has two fields. Both fields are databound...but the one field is a hyperlink field which works fine...but I would like to add a Request.QueryString value to the the value retrieved from the database when setting the navigateurl property. Help would be much appreciated

How do I use a inside a field in my GridView?

hi all, I am trying to add RequiredFieldValidator in some of my fields when my GridView is in "EDIT mode".How do I do that? This is what I use inside a table cell on my FormView:<td> <asp:RequiredFieldValidator ID="SettingID_RFV" runat="server" Display="dynamic" ControlToValidate="txtbox1" ErrorMessage="ID is required" SetFocusOnError="True" ValidationGroup="ItemInsertItemTemplateVG"/>* </td> How do I add this inside the fields of my GridView?? Thank you      

Set Field in Current Item to a previous version's field value

When using SPD, can you make a WF condition to set a field's value to it's previous version's value? Versioning is turned on for this doc library, but checkin/checkout is not on. These WF's run only after creation and editing, so I need to set a value back if a user doesn't have permission to set a choice column field to specific values. Thanks in advance, Chris

Get Text Value in Gridview from Invisible Field

Hello,  I've run into this before, but I was using a formsview and just changed the field to hidden.  If you've seen my previous post I am trying to get the value of a cell out of a gridview to a variable and here is the code: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged Dim varClientID As String = GridView1.Rows(GridView1.SelectedIndex).Cells(6).Text.ToString() End Sub This works perfectly if column 6 is visible, but because it's an id number (which is not the primary key) I do not want it visible, but changing it to visible="false" causes this code to return null.  Changing it back to visible and it works.I'm not sure why the visiblity of a control changes the functionality of it.Are there any other ways to get this data out?

Update a field in a gridview to False on a Button Click

 Hi, Ive got a list of records in a gridview (from an SQLDataSource) where a field value is set to True.  I've also added a "reset" button in a template field at the start of the row in the Gridview. What I would like to do is allow the user to click the reset button on a particular row and 'reset' the true value to 'false' (updating the source data). Are there any idiot proof tutorials to do this??? Many thanks for your help! Fiorano

Gridview with a linbutton in the template field

hi,i have a gridview as follows,<asp:GridView  runat="server" ID="gvPO"  AutoGenerateColumns="False"   >    <Columns>                    <asp:TemplateField HeaderText="PO No."><ItemTemplate>       <asp:LinkButton ID="lnkPo" runat="server" Text='<%#Eval("Purchase_order_no") %>' ></asp:LinkButton>   </ItemTemplate></asp:TemplateField>              </Columns>   </asp:GridView>The linbutton shows  Purchase_order_no.  When i clicked on a paricular purchase_order_no., it will navigate to another page with a gridview that shows details of that particular Purchase_order_no..... Pls help

Update a field that isn't in the row using a button in gridview


I have a gridview which shows a list of data... at the end of each item I have added a button which is linked to the onclick event... when a button is clicked I want a value to update on that specific row... but I can't get it to work :( my code is below...

SqlDataSource 1 code...

UpdateCommand="UPDATE [PurchaseProduct] SET [BDConfirmSent] = 'Yes' Where [Id] = @Id">

            <asp:Parameter Name="Id" />
            <asp:Parameter Name="BDConfirmSent" />

Code Behind...

Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating

        e.Command.Parameters("@BDConfirmSent").Value = "Yes"

End Sub

Protected Sub Button1_Click()


End Sub

When I click the button it just postsback the page but then the [BDConfirmSent] field is still empty instead of being "Yes"

Getting First record in Nextpage and last record of previous page of gridview



I am using paging to my  gridview (pagesize=4) . now i am in  (X) page and i want to get  (X+1) page top record or (X-1)page  bottom record , how i can get .


Using Button Field in GridView?

In .NET 1.1 to put in a link to download files from my server I used a Button Field in a DataGrid.

In .NET 2.0 I am trying to do the same with a GridView. 
In the Source of my page I put in <asp:ButtonField Text="Download" CommandName="Download"/>.
Then for the code behind I put in
Protected Sub GridView1_Download(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Download" Then
        End If
    End Sub
Download was a fuction and (e.Item.Cells(4).Text) would be the path to the file.  I noticed in a GridView I can't use
Is there a different way to do this?  Or should I not use a ButtonField and use something else?

How to Resize Button Field in gridview if we use Google chrome browser


Hi Everybody,

  I am using google chorme to test my asp.net application. In that <asp:buttonfield> control with in gridview is not resized. I am able to rotate text using following code.

 -webkit-transform: rotate(90deg);

But I am not able to resize the <asp:buttonField>.Please help me to resolve this.

Thanks in Advance.



Assign value of a current field to the value of a previous field


I am trying to assign a value to a row based on the value of a field in the previous row. In this case, I am able to identify where first left character of the item number of the previous row is 5. When this is true I need to display the value of the meal_typ field in each succsessive row until the condition is met again. So far the only thing that I have managed to do is pass the value to the first line.

I'm just not sure how to approach this issue. Perhaps there is a way to set a field in the main query equal to the result of the case in the subquery? Or perhaps there is a way to assign a variable to the subquery and set another variable equal to it in the main query? I haven't been able to make it work yet but I believe that there must be a way.

I am not able to use a stored procedure for this because I need to post this in our ERP systems "sql query requester" which does not recognize references to a stored procedure.

Here is the query i am using now and a sample of the current result set:

select cur.line_nbr, cur.item_nbr, cur.meal_typ, 

(select case when left<

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.
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