Change Header Text in the DataGrid on Selection.

Hi, 

I have a problem in inserting a combo box in to a Data grid Header which has an Img when click it has to display the Combobox for selection of the new column name.

I created a control which has a Span, Select box and an Img when clicks on the Img, it shows the select box for column selection and displays the column name in the span innertext.

But i am unable to use the same control for different columns as i used Div for hiding and displaying the combo box.

Can you please give me an idea on how to improve these sort of controls, which i can use mulitple times on the same webpage. Or if any link which has the similar controls is very much appreciated.

Thanks
Sai.

0
gvnspk
11/13/2008 6:49:45 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
434 Views

Similar Articles

[PageSpeed] 8

Hi gvnspk ,

Based on my understanding , you want to dynamiclly change the columns of DataGird according to the selection in combobox.

So I highly recommand you to implements custom Templates . When user change the selection of combobox, clear the columns of DataGrid, create one new custom Template and add it into DataGrid's columns collection , and rebind the DataGrid.

Implementing Dynamic ItemTemplates
http://scottwater.com/blog/pages/DynamicItemTemplates/
http://msdn.microsoft.com/en-us/library/0e39s2ck.aspx
http://www.developer.com/net/asp/article.php/10917_3609991_1

You said you have created one user control , and you want to reuse it . So I think you need to create one event for this user control , and when the select event of the combobox happens you can execute the event handler which is written in each page to change the Template I mentioned above .

 



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
11/17/2008 3:20:21 AM
Reply:

Similar Artilces:

Changing Header Text on a Datagrid
I have headers that post back to sort - I am attempting to change the text with each sort so as to indicate that is the current sort column and the sort direction howevere when I  do something like this it wipes out the link - can anyone please advise how to  thanks in advanve If e.Item.ItemType = ListItemType.Header Then e.Item.Cells(i).Text = "whatever" End If I've never had to do anything like that before, but i think you have to find the link in the header and change the text value. Do a google search, i'm sure something will pop up.  DarmarkMark as Answer, if ...

Changing the datagrid header text
Is this possible at all? I have an application that runs in different languages and I want to display the header in the current language (stored in the session). Thanks in advance Heki Yes, it is defenetely possible. You will have to use resource files to achieve that. Idea is - there will be one resource file to store the default string values and one resource file for each language you want to support. So, say i add two resource files to my project: MyForm.resx and MyForm.ru-RU.resx first being the default resource and second containing versions of the strings in Russian. ...

Change datagrid header text
I have a datagrid and I need to programatically change each column's header text based on user's previous input. I put the code in OnItemDataBound event like this:  if (e.Item.ItemType == ListItemType.Header) {  for (int i = 0; i <= e.Item.Cells.Count - 1; i++)  { e.Item.Cells[i].Text = "something"; } } The header text did get changed, but it changed it into static text which is not clickable so sorting cannot be performed. How do I change the header text but still make sorting enabled?It's been bothering me for a while now ... thanks a lot! Penn i am surprised ...

Datagrid column header text change
How to change the datagrid (MyDatagrid) column hedare text via load event without using itemdatabound event. Datagrid name: MyDatagrid column 2 text = OrderNo Thank you very much for the helpful info.     You can't! The Page.Load event is too early in the Page life cyce. You must wait until the ItemDataBound event or after.Thanks, EdMicrosoft MVP - ASP/ASP.NET Can you please tell me, how to change the header text of datagrid in the itemdatabound.   Thanks.   void DataGrid1_itemDataBound(object sender, DataGridItemEventArgs e)    { &nb...

Programmatically Change Datagrid Header Text
Hi, Can anyone please tell how to programmatically change the header text of a datagrid ? Thanks Phillip You have to change the header text in the ItemDatabound event. if(e.Item.ItemType = ListItemType.Header) { //If you have placed a label in the header.... Label lbl = e.Item.Controls[1] as Label; lbl.Text = "New header text"; } Also note that DataGridItem is derived from TableRow so you can do a lot of customizing.Mike Schellenberger - MCAD...

Changing Header Text of Datagrid Programatically
I have a datagrid. It is bound to an object data source.  I want to change the header text in one of the columns each time the data changes – which is basically at every postback.   By way of background, I created template fields using the Fields dialog box.  I have listed a portion of the code from the datagrid I am working on below.  I want to programmatically change  the headertext “services”.  I have tried using  findcontrol but I keep getting a null exception.  Any ideas would be appreciated. Thanks   <asp:TemplateField HeaderText=&...

How to change the Header Text of a datagrid column dynamically?
Hi ,  Can any one guide me on how to change the header text of a datagrid column dunamically in code behind? i am using the follwing code in datagrid item databound, but its not working  if (e.Item.ItemType == ListItemType.Header) {  if (Session["RoleID"].ToString() == "6" | Session["RoleID"].ToString() == "13") { e.Item.Cells[5].Text = "Select Record"; }Pradeep My personal way of doing it is to define a custom header. Then I can grab an instance of a lable or literal control in this instance in the ItemdataBound ev...

Can you control selectability of DataGrid column headers?
We have a DataTable with sorting enabled.  The person that I am working for has a complaint:  he wants the user to be able to select a column for sorting whenever the mouse is over the text in the header text of the column;  as things stand now, the cursor must be positioned  just below the text before the browser will allow selection.  Is there a way to control this, or  is this functionality that is internal to the browser? This behavior appears to only be an issue in Internet Explorer, not Firefox. the sort headers are simply an anchor...

Getting Selected text from DataGrid Header DropDown.
I have a dropdownlist in DataGrid Header. On press of a button i want to get the selected text of that dropdown. I have writte the following code:protected void Button1_Click(object sender, EventArgs e) {DataGridItem header = (DataGridItem)dgtest.Controls[0].Controls[0]; DropDownList dlID = (DropDownList)header.FindControl("ddlID"); string value = dlID.SelectedItem.Text; } Here value always gives me zero index item of DropDown irrespective of value selected in DropDown. What can be the problem??If you found this post helpful. Please mark it as answer. try this&nbs...

Datagrid selected item and change text of hyperlink
OK I got most of this to work but not the way I want it to yet, I would like to make some enhancements.... I'm more of a VB code behind guy because I come from VB6... but always willing to learn more ASP.... I have looked around a lot and tried a lot of things I have seen but I must be missing something somewhere... This is what I want to happen.... I load data to a datagrid and the first column is a hyperlink column and when the user clicks a row, I then grab the value in the first cell of that row then Jump to page 2 within the same project and put that value in a textbox but... ...

Weekdays changing dynamically in Datagrid Column Header Texts
Dear All,I hav a prob.I hav a table t_custinfo containing customer ID,name and personal details.Now I hav a datagrid where in I hav to retrieve custID and custname in two columns.In other columns I need to display weekdays say Mon to Sun with dates..The weekdays hav to change dynamically.In the grid user enters the amount collected from the customers for ex:CustID Custname Mon-2/2/06 Tue-3/2/06 Wed-4/2/06....till Sun-..1      bharath   100          2000      1000   2  ...

changing text in static text control
Hello PB 11 build 8123 I have a window with a dwcontrol. When I am updating the dw control I want one of the column names (static text controls) to change based on a value I select in another column. So far I have the code in the itemchanged to capture the value of my selection in the field I first select. How do I take this value, (it can only be Y or N) and program one of the column headings (static text) to display a certain text? I can't seem to get it to work with setitem or settext. Those two funcs don't really work with column headings as far as I can see. A...

Changing column header text of a gridview inside user control
Hi,I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that:foreach (DataControlField col in GridView1.Columns){ col.HeaderText = GetString(col.HeaderText);}However, no matter where I place that code, the header texts return to their original value, and that's what's being displayed.What could be the reason for that? And how can it be solved?  ...Anyone? I'm having the feeling that I'm missing something quite basic here, any help would be very appreciated. Amit00: col.HeaderT...

Changing the text of an input (text) control
Hi everyone, please answer the following: I have a html input control as follows  <input id="newSearch_keywords" type="text" class="text" value="<%=JobsSearchBusinessObject.CurrentKeywords %>" name="newSearch_keywords""/>    When the page loads I need to look at the text of this input field and remove any * chars that are in the text. Thanks for your help <input id="newSearch_keywords" type="text" class="text" value="<%=JobsSearchBusinessObject.CurrentKeywords.Re...

Web resources about - Change Header Text in the DataGrid on Selection. - asp.net.presentation-controls

Selection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Multi-state plans and selection problems
... often similar in design. In fact, it may be hard for consumers to tell them apart. The short answer is network and the longer answer is selection. ...

Ed Feng's College Football Playoff Standings Predictions Before Selection Sunday
Bleacher Report Ed Feng's College Football Playoff Standings Predictions Before Selection Sunday Bleacher Report Will your team make the College ...

Hulu to offer lulu of a video selection
Site created by NBC Universal and News Corp. to debut Wednesday with shows from more than 50 TV networks, cable stations, and movie studios. ...

After Protest, VA Rescinds Selection Of Phoenix VA Overseer Who Misled Congress About Wait Times
After Protest, VA Rescinds Selection Of Phoenix VA Overseer Who Misled Congress About Wait Times

The Astronaut Hopeful's Manifesto: An Insider's Guide To NASA Astronaut Selection
Almost everyone wants to be an astronaut at some point in their life. Here's an insider's guide from an adult who hasn't given up on that dream. ...

AP PHOTOS: A Selection of Pictures From the Past Week
AP PHOTOS: A selection of pictures from the past week

Today’s selection of articles from Kotaku’s reader-run community: Naruto Shippuden
Today’s selection of articles from Kotaku ’s reader-run community: Naruto Shippuden - The Filler Free Viewing Guide (Pt. III) • Spacemon: A Pokémon ...

AP PHOTOS: A selection of pictures from the past week
Albuquerque’s source for local news and live streaming video online. KRQE reports on news, weather, traffic, investigations and sports for New ...

Nonlinear optical selection rule based on valley-exciton locking in monolayer ws 2
Nature.com Nonlinear optical selection rule based on valley-exciton locking in monolayer ws 2 Nature.com Article - PubMed - CAS - ; Chernikov ...

Resources last updated: 12/23/2015 4:46:07 AM