how to add string in row header of dataGrid? #2

hi there, 

I just want to know that can we add values or string displayed in the row header of a grid which is use to select the whole tuple ie ,row. If we can then pls let me know how.
hope that i get the response as soon as posible.
thanks
Regards
DeadRocker
0
deadrocker
2/18/2005 5:34:25 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
655 Views

Similar Articles

[PageSpeed] 53

Actually I couldn't understand exactly what do u mean, but if what you want is to add a clickable text in the header of a data grid to let the header be selected, if so then try to read this:

I don't know if the header can be selected directly, but I don't think so, but there is a tricky way: by adding a normal button or a link button to the header of the data grid (*), and to add code that changes the back color of the header, this will seem as it is selected.
(*) for how to add this button in the header do the following:
1. right click the data grid, then select property builder.
2. select columns, and add a template column, then close the property builder window.
3. right click the data grid and select edit template and choose the column u have just added.
4. the grid appearence will change to seperate the header,item and footer, so u can add a button to the header place.
5. set the (command name) property of the added button to something (SelectHeader) for example.
6. view the code of the page and add this code to the data grid item command event:
if e.CommandName = "SelectHeader" Then
DataGrid.HeaderStyle.BackColor = Color.Yellow
End If

I hope this would help, otherwise plz re-post to clear the idea
0
net
2/18/2005 6:43:04 PM
Hi,
I have followed your instructions to the letter, as far as I'm aware, but the code still does not work! I cannot figure this one out, please help? See my complete code below...

WebForm3.aspx:
WebForm3WebForm3 <code>
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>WebForm3</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:TemplateColumn>
                        <HeaderTemplate>
                            <asp:Button id="Button1" runat="server" Text="Button" CommandName="headerbtn"></asp:Button>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem").ToString() %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
        </form>
    </body>
</HTML>
</code>
WebForm3.aspx.cs:
<code>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace test
{
    /// <summary>
    /// Summary description for WebForm3.
    /// </summary>
    public class WebForm3 : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.DataGrid DataGrid1;
   
        private void Page_Load(object sender, System.EventArgs e)
        {
            ArrayList list = new ArrayList();
            list.Add( 1 );
            list.Add( 2 );
            list.Add( 3 );
            DataGrid1.DataSource = list;
            DataGrid1.DataBind();
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }
       
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {   
            this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

        private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            string a = e.CommandName;
        }
    }
}
</code>
matt.

This post with no guarantees associated, being a personal submittal with no affiliation intended or implied.
<mc:WittyRemark runat="server" id="wr1" />
0
matthewwebster
4/22/2005 1:38:22 PM

Ok, I know the code I just posted doesn't try to select the header, but I'm just trying to get the button IN the header to fire an event, of some sort.

At present this is not happening. When it does I'll get it to select the header or whatever I want it to do.

I actually want this so I can do things like add a new record to a table.

matt.


This post with no guarantees associated, being a personal submittal with no affiliation intended or implied.
<mc:WittyRemark runat="server" id="wr1" />
0
matthewwebster
4/22/2005 1:40:40 PM
Reply:

Similar Artilces:

how to add string in row header of dataGrid?
hi there, I just want to know that can we add values or string displayed in the row header of a grid which is use to select the whole tuple ie ,row. If we can then pls let me know how. hope that i get the response as soon as posible. thanks Regards DeadRocker Do you mean that? Sub OnItemCreated( ByVal e As DataGridItemEventArgs ) if e.item.itemtype = ListItemType.Header the...

How to add dynamic row in between 2 existing rows in datagrid?
Is this possible to add dynamic rows in middle of the rows in datagrid?I want to find net total like thisPNo   SNo  status  day1  day 2  day3001     S01   Pack   10     30      20                    Used   05     01      20001     S02   Pack   20     10 ...

Datagrid: Add a Main header row, above the column headers
Is this possible?  How is this done? -smc~ Remember To Mark The Posts Which Helped You As The ANSWER ~ Yes...Handle the ItemCreated event.  I have a sample using the GridView that can give you the idea http://www.webswapp.com/codesamples/aspnet20/nestedgridviews/default.aspxHTH,Phillip Williams,http://www.webswapp.com Do you have any examples using DataGrid in VB? Can the Header be displayed above the column headers?  -smc~ Remember To Mark The Posts Which Helped You As The ANSWER ~ http://www.societopia.net/samples/dataGrid_customheader.aspxHTH,Phillip Williams,http:...

Datagrid Header 2 Rows
Hello All, I have a datagrid that I want to have multiple lines in the Header. Does anyone know how to accomplish this?? Any help is much appriciated. Thanks, Larry In the header, just put a <br> tag in between the first and second "lines" of the header. This will force a newline. Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Thanks for the feedback. How would i do that promatically. I am building the datagrid dynamically and need to do it through code. Thanks in advance, Larry How ...

Add row in datagrid #2
I have a datagrid with 3 template columns(2 text boxes and 1 dropdownlist) with custom binding. I have a buuton add row . On click of addrow a new row should be inserted  with textboxes and  dropdownlist. how to do it? http://www.superdotnet.com/Article.aspx?ArticleID=149Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4)....

Add row in datagrid from other controls
Hello all, I am using the VS.2003.I would like to add a row in a datagrid, the data will come from other controls. I am having 2 textboxes (name, surname), 1 dropdownlist (sex) and a datagrid. I want to enter some values into these controls and when i am pressing a button (add) to insert them into datagrid row (the columns are also: name, surname and sex).The other issue is that i should add the ability of editing the values in the datagrid by pressing "Edit" button (it exists in each datagrid row). And the datagrid columns will have to be also 2 textboxes and 1 dropdownlist (jus...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

How do I "row-wrap" ? i.e., have 2 rows of headers, and 2 rows in grid for each data record?
Hi I have built a view in Sql Server, and built my Sql Data Source, and everything looks good... I have my data grid populating nicely. But, I want the headers and rows to wrap - not inside each cell, but to fit the page. Let's say I have 10 columns, and only 5 will fit in the width of a webpage.  I would want the headers to wrap, so there are two rows of headers, then each data record would fill 2 rows in the grid. Example:  <headers> Last Name................First Name.............. Middle Name.............DOB............SSN............. <end of this row in grid>...

ANN: EasyQuery.NET WinForms 2.2.1
We are proud to announce EasyQuery.NET WinForms version 2.2.1 release. EasyQuery.NET is a set of native .NET classes, components and controls which help you (as a developer) to include end-user-oriented query builder into your Windows Forms application. It provides your users with ability to describe their requests in natural language instead of complicated SQL or QBE statements. Unlike other query builders that require from users some knowledge about relational database concept, tables, views, etc, our solution allows to operate with simple and understandable entities and predi...

Datagrid(.net 1.1) to GridView(.net 2.0) and using the RowUpdating event how to extract the values from the controls.
Ok  This is the settings: I use a Viewgrid with only itemtemplate colums for example. <asp:TemplateField HeaderText="Test"><ItemTemplate><asp:Label id="LBL_Test" text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' runat="server" meta:resourcekey="LBL_TestResource1"></asp:Label></font></ItemTemplate> <EditItemTemplate><asp:TextBox ID="HDN_Test" Text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' Runat="server" meta:resourcekey="HDN_TestResource1" /></EditItemTemplate></asp:TemplateField>  The ...

Add a second Header-Row to DataGrid
Hi! I want to add to my DataGrid a second Header-Row in which i place textboxes...so the user can enter search terms for the desired fields... I really don't know how to... Thanks in advance! Hi, Take a look @ Extending DataGrid in ASP.NET HTHK B ShajudeenAreYaar.comDubai, United Arab Emirates. Oh that looks good to me.. Thanks!...

datagrid with a headers header row
Howdy! I am using a datagrid and I have all the rows and then a header row explaining each column, but I want a row above that as part of the table explaining the table. Thoughts? Cheers Can you explain more clearly what you want? Okay, A normal datagrid has the data fields and the header fields where the header fields are a one to one correlation to the data fields and are used to descibe the data fields. That is perfect as well, but I want to put a title on the datagrid above the header fields to use a couple of words to describe the table itself. There will be s...

Add-in Express 2 .NET Edition 2.2 Released!
It is a tool for creating COM Add-ins, Smart Tags and RTD in .NET. Add-in Express supports Outlook, Excel, Word, PowerPoint, Visio, Project, MapPoint and Publisher and developed for C#, Visual Basic .NET (VB.NET), J#, C++ and Delphi. It implements everything required by the supported technologies such as IDTExtensibility2, ISmartTag and ISmartTagTopic and allows you to write functional code only. Read more at http://www.add-in-express.com More info: http://www.add-in-express.com/...

Cannot Add a blank Row to databound datagrid with Checkbox control
Hello, I think I am posting this question again but I'm quite frustrated as I haven't found any way around. I have a databound datagrid in which New/Blank rows are added to this datagrid on a button click event. This button is outside the datagrid and not in the footer. The datagrid populates well and I can do the edit/update to the already created records. I recently had to add a new checkbox field to my data table. This chekcbox field is to be included in this datagrid. The chkbox works fine for previously created records but as soon as I hit the 'Add New Row' button I get the following ...

Web resources about - how to add string in row header of dataGrid? #2 - asp.net.presentation-controls

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012

license-discuss@opensource.org: 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 12/7/2015 12:14:55 PM