.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

GridView, TemplateField and ButtonField

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
 
I have a grid view in which i have  1.5 boundfields 2.A templatefield containing a dropdownlist having values accept and decline 3.A buttonfield with TextProperty as ok After selecting Accept in dropdownlist and clicking on the OK button, The row of a status column in one of my Database Table should be updated from No to Yes. If the user selects Decline in the dropdownlist and then clicks on the OK button, I want that row to be deleted. I also have a unique id as boundfield in the GridView. Please advise how to achieve this HI All,I have a grid view in which i have -a)5 BoundFieldsb)A TemplateField containing a dropdownlist having values accept and declinec)A ButtonField with TextProperty as OK.After selecting Accept in dropdownlist and clicking on the OK button, The row of a status column in one of my Database Table should be updated from No to Yes.If the user selects Decline in the dropdownlist and then clicks on the OK button, I want that row to be deleted.I also have a unique id as BoundField in the GridView.Please advise me how to achieve this


View Complete Post


More Related Resource Links

Templatefield CheckBox in gridview acting strange

  
I have an ASP.NET page that contains a gridview. I have to create columns dynamically based on a datatable, some field type info and some header texts. I do that by creating templates. It created the grid fine and all looks good, however when i click a checkbox and the checkedchanged event fires then something odd happens The first time i click its fine and i get the expected values in the event But the second time then the event gets fired with the values from the first time and then again with the values from the checkbox that i actually clicked.. The third time the event gets fired 3 times, first 2 times with the old values and the third with the correct value. And it just keeps going like that Furthermore Let us say i have 10 checkboxes that are checked when i uncheck one the checkedchanged event fires but if i check it again the event doesnt fire and also if i have unchecked 3 checkboxes(and get the extra events) then if i check one of them again i get 2 checked changed events fired for the ones that are still unchecked but no event gets fired for the box that i checked  so now im just baffled   See pastebin link below for code: http://pastebin.com/stcwqsYa 

Dynamic templatefield disappear during gridview rowcommand

  
Hi,   I already implemented the dynamic templatefield which will re-created in every postback. Everytime I make a postback in the page I see no problem but when I click my imagebutton inside the gridview then the dynamic templatefield disappear. To double check if it is really gone at all I just select the second page of the gridview using my customize paging using dropdownlist outside the gridview and the templatefield with its correct data reappear again. I already put a variable inside the rowcommand to see if the number of columns are the same with the number of columns the gridview render together with the dynamic templatefield during debugging and it is there but cannot render that templatefield in the client.   Any ideas? 

no data in gridview templatefield

  
I have a gridview bound to a objectdatasource, when I try to convert one of my columns to a template field the data doesn't displayBefore converting <asp:BoundField DataField="ID" Visible="false" /> <asp:BoundField DataField="Contract" HeaderText="Contract" /> <asp:BoundField DataField="Tender" HeaderText="Tender" /> After converting <asp:BoundField DataField="ID" Visible="false" /> <asp:BoundField DataField="Contract" HeaderText="Contract" /> <asp:TemplateField HeaderText="Tender"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Tender") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("Tender") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> Im usig the option in the gridview smarttags Convert this field into a TemplateField . When run as a bound field the data appears, when run as as template the data doesn't, Is there something I'm missing?    

GridView - putting TemplateField fields in between data bound fields

  

Here is my problem.  I have a GridView, and I want Column1 to be equal to datatable data (filled by a SqlDataAdapter).  Then I have two other fields by the SqlDataAdapter (first name, last name), and I want to have those two fields combined to form Column2.  I have a TemplateField for my GridView that combines the first name and last name with Eval()'s, but the GridView places this combined field TemplateField and puts it as the first column.

How can I do this so that TemplateField can go in between fields that are databound?  Thanks in advance. :)


Gridview: can we use asp:TemplateField and asp:BoundField both in a single grid??

  

Hello everybody

can we use asp:TemplateField and asp:BoundField both in a single grid??

If yes then how to handle deleteCommand on serial number. mean to say how to write query for that field as it is not any column of databse..

for e.g--

 

<Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                <asp:TemplateField HeaderText="Serial No">
                    <ItemTemplate>

Accessing GridView TemplateField using Javascript

  

Hi,

I have a GridView in which i have some Template Fields including a button as template field also here is the link which i have implemented so u will know what i am talking about. problem is that on clicking of UpdateButton I am calling a javascript to save values of template field boxes of particular row but I cannot access the template field textboxes from javascript. how to do that.

http://fun2code.blogspot.com/2008/07/nested-gridview.html

now my problem is that i have update button in that nested template area which is calling a javascript to update the particular grid row nested data using AJAX.

here is my version the way I am doing.

   <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" DataKeyNames="Bill_Generation_ID"
        DataSourceID="SqlDataSource1" 
            OnRowDataBound="GridView1_RowDataBound" CellPadding="3"
        GridLines="None" EnableModelValidation="True" BackColor="White" 
            BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1" 
              CssClass="mGrid" Font-Names="Verdana" Font-Size="12px">
 
        <FooterSt

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.

GridView Paging Using Ajax 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.

Displaying Row Details Tooltip on GridView using JQuery

  
Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.

jQuery: Highlight Gridview Rows with Checkbox

  
Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

Sortable GridView using jQuery's TableSorter

  
This article explains how to use jQuery's plug-in Tablesorter to implement client-side sorting in an ASP.NET GridView. This comes in handy especially when an ObjectDataSource is used with a GridView as GridView does not provide sorting out of the box.

Sorting Gridview using Jquery with ASP.NET

  
I want to show how to sorting a gridview using a Jquery in ASP.NET, it is a flexible client-side table sorting. We have known that Jquery is a new kind of Javascript Library. You can find detail of Jquery in this site http://jquery.com/ there are lot of example with documentation and also allow free download a latest version.
Categories: 
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