remove a gridview column dynamically, removes controls in template columns

I have a interface with a treeview and a gridview. The gridview has two templatefields that handles insert/update/deletes. The gridview is handling editing of different tables so I create the other columns in the gridview dynamically as boundfields. The user selects the table to edit in the treeview.

The problem I am having happens when the user selects a table to edit the second time. The code that executes removes all bound fields, (dynamically added when user selected the first table in the treeview), but not the two template fields, and then adds boundfields specific for the selected table. The problem (bug ?) is that this removes all controls (Imagebuttons) in the template fields.

So, to reproduce, just remove a column in i gridview with template fields. This will remove all controls in all the template fields. (I haven't tried the result if removing predefined columns)

If I use commandfield's instead of templete fields the code works fine. But... I don't want to do that.

Greatful for every suggestion.

0
ThePingwin
9/24/2007 8:53:09 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

16 Replies
3184 Views

Similar Articles

[PageSpeed] 2

Hi:

  Please paste a demo that can reproduce your problem.

Thanks


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-1
Allen
9/27/2007 6:45:13 AM

Thanks for the reply. 

I will paste how the gridview looks in the aspx. The gridview is really in some divs, (to handle x-y scrolling) and a updatepanel and the gridview really has a couple of headertemplates with updateprogresscontrols, but I have verified that it isn't affecting the behaviour. Also the events wired to the gridview doesn't affect behaviour. And the events wired to the sqldatasource are only handling errors.

To reproduce:
1. Let your page load without any code when postback = false.

2. First postback add one or more boundfields.

3. second postback remove one ore more of the bound fields. I do this in the page_load() event. (I have a solution where the underlying table is changing by selection in a tree view so I am also adding new boundfields here).

4. Fourth postback. The controls in the predefined template fields are gone.

If you cant reproduce please send me your copy so I can compare.

The gridview.

<asp:GridView ID="GridViewBasAdm" SkinID="MainGrid" runat="server" DataSourceID="SqlDataSourceBasAdm"

AutoGenerateColumns="false" OnRowUpdating="GridViewBasAdm_RowUpdating" OnRowUpdated="GridViewBasAdm_RowUpdated"

OnPreRender="GridViewBasAdm_PreRender" OnRowCommand="GridViewBasAdm_RowCommand"

OnRowDeleting="GridViewBasAdm_RowDeleting" meta:resourcekey="GridViewBasAdmResource1">

<Columns>

<asp:TemplateField ConvertEmptyStringToNull="False">

<ItemStyle Wrap="False" />

<ItemTemplate>

<asp:ImageButton SkinID="EditInGrid" ID="ImgBtnEditInGrid" runat="server" CommandName="Edit" />

<asp:ImageButton SkinID="DeleteInGrid" ID="ImgBtnDeleteInGrid" runat="server" CommandName="Delete"

OnClientClick="return DeleteMsg()" />

</ItemTemplate>

<EditItemTemplate>

<asp:ImageButton SkinID="NewInGrid" ID="ImgBtnNewInGrid" runat="server" CommandName="Update"

meta:resourcekey="ImgBtnNewGridFoljesedelkomplResource1" />

</EditItemTemplate>

</asp:TemplateField>

<asp:TemplateField ConvertEmptyStringToNull="False">

<ItemStyle Wrap="False" />

<EditItemTemplate>

<asp:ImageButton SkinID="UpdateInGrid" ID="ImgBtnUpdateInGrid" runat="server" CommandName="Update" />

<asp:ImageButton SkinID="CancelInGrid" ID="ImgBtnCancelInGrid" runat="server" CommandName="Cancel" />

</EditItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSourceBasAdm" runat="server" OnUpdating="SqlDataSourceBasAdm_Updating"

OnUpdated="SqlDataSourceBasAdm_Updated" OnDeleted="SqlDataSourceBasAdm_Deleted"

OnSelected="SqlDataSourceBasAdm_Selected"></asp:SqlDataSource>

0
ThePingwin
9/27/2007 8:30:48 AM

I forgot to mension that I found to threads with very simular problems:

 http://forums.asp.net/t/1083065.aspx
http://forums.asp.net/t/1066879.aspx

0
ThePingwin
9/27/2007 8:33:44 AM

Hi:

ThePingwin:

1. Let your page load without any code when postback = false.

2. First postback add one or more boundfields.

3. second postback remove one ore more of the bound fields. I do this in the page_load() event. (I have a solution where the underlying table is changing by selection in a tree view so I am also adding new boundfields here).

4. Fourth postback. The controls in the predefined template fields are gone.

  So where's the third postback? I'm confused now. I think it's fine if you could paste a concise and clean demo that can reproduce your problem. BTW, when dynamically adding controls we shall add it in every postback. And it's better to do this in Page_Init, which is before Loading ViewState.

Thanks


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Allen
9/27/2007 9:07:44 AM

Sorry, but it seems like I can't count. It's not the fourth but the third postback described in the example.

Sorry also for being more than acceptable confusing.

It is very simple to reproduce. Take any aspx page with gridview and a sqldatasource that works and have a templatefield in it. I don't think it matters what kind of controls it has but to be sure you can add one of my template fields above. Create a button with the following code in the click_event:

GridFoljesedelkompl.Columns.RemoveAt(GridFoljesedelkompl.Columns.Count-1);

Let the grid load with data and click the button and you will notice that the controls in the templatefield dissappears.

I think this will be a lot faster than me sending you a example with a datasource.

Thanks

0
ThePingwin
9/28/2007 2:52:46 PM

Hi:

  Set a breakpoint here and check the value of GridFoljesedelkompl.Columns.Count you'll see auto generated columns is not in Columns collection.

  GridFoljesedelkompl.Columns.RemoveAt(GridFoljesedelkompl.Columns.Count-1);

  To remove the last column, try:

 protected void Button1_Click1(object sender, EventArgs e)
    {
        foreach (GridViewRow r in this.GridView1.Controls[0].Controls)
        { r.Cells.RemoveAt(r.Cells.Count - 1); }
       
    }

Regards


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Allen
10/1/2007 7:51:23 AM

Hi,

I don't have any auto generated columns in my solution. (if you see the code I send the gridview has autogeneratedcolumns=false). I create my columns in code, look below for the code. I have no problems removing the last column. The problem is that the template fields, (column 0 and 1), controls disappers when removing any other column.

(The functionality of the page is that the user selects a table to edit in a treeview. I am adding the tables columns in the grid. When the user changes table in the treeview I am removing every column but the tf columns, and then adding the selected tables columns.)

But to reproduce you only need to remove any column, in a working gridview/sqldatasource - solution, but the TF columns.

Regards // Petter

Code for adding columns

protected void AddGridcolumn(string colname, string type, bool colreadonly)

{

try

{

BoundField bf = new BoundField();

CacheControllerBase l_Controller = CacheControllerFactory.Factory("BAA");

DataRow attributename = l_Controller.InCacheRow(0, colname);if (attributename == null)

{

bf.HeaderText = colname;

}

else

{

switch (Profile.Sprak.Substring(0,2))

{

case "sv":

bf.HeaderText = attributename[1].ToString();

break;case "en":

bf.HeaderText = attributename[2].ToString();

break;

case "de":

bf.HeaderText = attributename[3].ToString();

break;default:

bf.HeaderText = attributename[0].ToString();

break;

}

}

bf.DataField = colname;

bf.ConvertEmptyStringToNull =
true;

bf.ReadOnly = colreadonly;

bf.HtmlEncode =
false;

type = BasAdm.setParameterType(type).ToString();

switch (type)

{

case "Int32":

bf.DataFormatString = "{0:F0}";

bf.ApplyFormatInEditMode = true;

break;

case "Decimal":

bf.DataFormatString = "{0:F2}";

bf.ApplyFormatInEditMode = true;

break;

case "DateTime":

bf.DataFormatString = "{0:d}";

bf.ApplyFormatInEditMode = true;

break;

default:break;

}

GridViewBasAdm.Columns.Add(bf);

}

catch (Exception exc)

{

throw new Exception("", exc);

}

}

0
ThePingwin
10/1/2007 11:27:11 AM

Hi:

  I tested this. It works fine:

     <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
        <Columns><asp:TemplateField><ItemTemplate>
        Template_Field
        </ItemTemplate></asp:TemplateField></Columns></asp:GridView>

        <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Remove" />

    protected void AddGridcolumn(string colname,  bool colreadonly)
    {

        try
        {

            BoundField bf = new BoundField();

            bf.DataField = colname;

            bf.ConvertEmptyStringToNull = true;
            bf.ReadOnly = colreadonly;

            bf.HtmlEncode = false;
             
            GridView1.Columns.Add(bf);

    }

        catch (Exception exc)
        {

            throw new Exception("", exc);
        }

    }

 

   protected void Button3_Click(object sender, EventArgs e)
    {
        this.GridView1.Columns.RemoveAt(this.GridView1.Columns.Count - 1);
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        AddGridcolumn("theName", false);
    }

  From your description it seems a Page Life Cycle issue. Please add columns in Page_Init. You can set breakpoints to check whether the GridView currently contains the newly added column.

Thanks


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Allen
10/3/2007 2:22:57 AM

Hi again,

Tried your code with a imagebutton added to the templatefield, and I got the same error. I then tried with 2 bound fields predefined and didn't add any columns, but removed the predefined, and same error. I am sending you the code so you can see if you can reproduce.

Thanks

 aspx-page (change SqlDataSource.SelectCommand  to something that returns rows, and change the boundfields DataField boundfields )

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Theme="Default" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Bip %>"

SelectCommand="q_getall_q_lossningssatt" SelectCommandType="StoredProcedure">

<SelectParameters>

<asp:Parameter DefaultValue="0" Name="foretagkod" Type="Int16" />

</SelectParameters>

</asp:SqlDataSource>

<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Remove" />

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">

<Columns>

<asp:TemplateField ConvertEmptyStringToNull="False">

<ItemStyle Wrap="False" />

<ItemTemplate>

<asp:ImageButton SkinID="EditInGrid" ID="ImgBtnEditInGrid" runat="server" CommandName="Edit" />

<asp:ImageButton SkinID="DeleteInGrid" ID="ImgBtnDeleteInGrid" runat="server" CommandName="Delete"

OnClientClick="return DeleteMsg()" />

</ItemTemplate>

<EditItemTemplate>

<asp:ImageButton SkinID="NewInGrid" ID="ImgBtnNewInGrid" runat="server" CommandName="Update"

meta:resourcekey="ImgBtnNewGridFoljesedelkomplResource1" />

</EditItemTemplate>

</asp:TemplateField>

<asp:TemplateField ConvertEmptyStringToNull="False">

<ItemStyle Wrap="False" />

<EditItemTemplate>

<asp:ImageButton SkinID="UpdateInGrid" ID="ImgBtnUpdateInGrid" runat="server" CommandName="Update" />

<asp:ImageButton SkinID="CancelInGrid" ID="ImgBtnCancelInGrid" runat="server" CommandName="Cancel" />

</EditItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="q_lossningssatt" HeaderText="q_lossningssatt" SortExpression="q_lossningssatt" />

<asp:BoundField DataField="q_lossningssatt" HeaderText="q_lossningssatt" SortExpression="q_lossningssatt" />

</Columns>

</asp:GridView>

</asp:Content>

 

codebehind:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button3_Click(object sender, EventArgs e)

{

this.GridView1.Columns.RemoveAt(this.GridView1.Columns.Count - 1);

}

}

0
ThePingwin
10/3/2007 8:02:00 AM

Hi:

  Do you mean click "remove" and then after another postback the controls in ItemTemplate disappear? It seems a known issue:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102901

  To work it around, you can try to remove TableCells instead of the columns.

 foreach (GridViewRow gvr in this.GridView1.Controls[0].Controls) 
        {
            
            gvr.Controls.RemoveAt(index);//Change index
        }
Regards


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-1
Allen
10/3/2007 8:50:01 AM

Thanks,

I think I will have to work on my explination skills:-)  To focus on the problem and not try explain things in the solution not intresting.

Conclusion: I will try the workaround, but it seems like it has a drawback that make it useless for me. What happens if you dont have any rows in the gridview.

Final question: This has obviously been a known issue for a long time. Is it going to be fixed, and if so, when ? If it's not going to be fixed my suggestion is take away the remove method on columns to spare people some headache.

Thanks again

0
ThePingwin
10/3/2007 11:52:59 AM

Hi:

ThePingwin:
This has obviously been a known issue for a long time. Is it going to be fixed, and if so, when ? If it's not going to be fixed my suggestion is take away the remove method on columns to spare people some headache

  I'm not sure whether it is going to be fixed. But from the feedback it seems will not be fixed in the next release.

Quote:

Unfortunately, this bug falls into the red bits category, and so we are not able to address it in Orcas due to the potential for it to introduce compatibility issues.

  For now we could only find some workarounds. If you have a better idea you can also post it here, which would be a greate help to other community members.

Thanks


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Allen
10/4/2007 1:05:57 AM

Thanks for all your help Allen.

I have two workarounds (none as clean as the one you presented)

1. Create all columns dynamically on every postback (also the TF fields). This in the page_init event.

2. Do a redirect to the same page when the columns needs to be removed.

//best regards

0
ThePingwin
10/4/2007 6:53:31 AM

I have a similar problem but your workaround doesn't help. I have a gridview that shows the fields of two types of objects. The first type requires all the columns. The second type requires all but two of the columns. When I have an object of the second type, I remove the two unneeded columns. All of that worked until I began using template fields for one of the other (unremoved) columns. When initially displayed, the itemtemplate displays properly. However, when I press the edit key, the edittemplate controls don't show up. Further, when I press cancel, the original itemtemplate no longer displays.

 I tried your workaround and another workaround as well. The other workaround basically hides the two columns instead of removing them. This causes the templates to work properly, but introduces another problem. The two previously deleted columns contain dropdownlists which now have invalid values. This is expected because the type of object being displayed has null values for these two columns. Before, when I was deleting the columns, the dropdownlists were deleted along with the columns so there were no errors. Now that they are just hidden (or the cells removed) the dropdownlists are still there and giving "value not in dropdownlist" errors.

 Any ideas? This problem is realllllly annoying.

P.S. One thought I had was to use two totally separate gridviews, one for each type of object and just disable the one I wasn't using. Not very elegant but perhaps this could work.

0
markkesty
10/21/2007 8:21:54 PM

I am sorry for the work arounds, they are not pretty. In my solution I am currently doing a redirect to the same page with settings in the url. It is working for me since the grid's columns are removed seldom in my functionality.

Have you tried to empty the databound attribute (Selectedvalue/selectedindex) of the ddl's in TF when the TF is hidden. That should make your solution work.

0
ThePingwin
10/22/2007 7:23:03 AM

 Thanks, Allen Chen,

This was pretty helpful for me.


Regards
KINJAL

"Mark the post as answered if it solves your Query"
0
kinjalin
4/9/2009 12:53:35 PM
Reply:

Similar Artilces:

Dynamic Slave Controls
I am working a solution to enhance slave controls. I have created a proof of concept based on the 2.04 code base that shows how to load slave controls without switching to the admin view. I have included a sample module that contains 3 view controls. Each control has a row of buttons that can be used to load one of the other 2 controls. (and no I am not using panels.) The default control has a drop down of other instances of the dynamic control that exist on the current tab. Using the module communicator you can raise an event from one control that tells another instance of the module what c...

Dynamically create controls in GridView template column
Hi,this is my first post so please be nice :)I have a situation where I'm loading GridView from XML data source and I need to dynamically create a TABLE control inside grids template column.One of table's columns has an editable TextBox, so there could be unknown number of rows in a gridview and unknown number of rows in each table.At the moment I'm creating those tables inside  GridView_RowDataBound event and all works fine.Problem is that when user clicks in "Update" button table controls are gone because they are dynamically created.My question is how can I crea...

Issue with Template Columns & Bound Columns while updating the data in a GridView control
Hi, I'm facing the below problem (In general, ObjectDataSource is driving me crazy ! ) I have a simple gridview control and an ObjectDataSource is used to populate the grid. I'm trying to update a row and the corresponding tableadapter methods & stored procedure are in place. Each row has 2 checkboxes and 2 textboxes in edit mode. When the change the values in edit mode and hit update, the checkbox values changed are saved into the Database properly, whereas the textbox values are not being saved. If the textbox column is a bound column then the column is updated with <NULL> in...

Gridview control removing consecutive spaces in column output
 Hi, i am using a simple GridView to retrieve data from a SQL view, and if there are consecutive spaces in the string in a particular column, something (asp?) is removing the 2nd space, and then the output has only 1 space, which is incorrect for this string. Interestingly, if I retrieve the same column with a specific select statement in a code behind file, and then output it via either response.write, or in a text box, it does the same thing.   I have debugged while doing this and in the Autos window, the string is correct (with two consecutive spaces), then when it is ...

How can I control the width of a column in the GridView control.
From searching I see mention of ways to do it before the controls are bound. Is there a simpler way? If not, could someone explain to me how I need to go about it?Here is the code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">   &nbs...

GridView Dynamic Column, Controls
Hello I have a data grid, i define its edittemplete , itemtemplete in .cs file because i need things dynamic, i dont want any Select , Edit , Update Button on Grid,i made my grid click able, when i click on row , its show row in edit  version fine yet, but when i click ne other row its dont make changed in last row ? how could i bind it ? do we must need to put updated button? plz help uswe need to giv look of desktop grid?let me know if you have any query?  Umer KhanSr. Software EngineerUmer.Khan@systemsltd.com------------------------Click "Mark As Answer" iff,It he...

Remove dynamicly columns from an gridview
Im making an c# class library project with an dataset and an gridview. Everything works fine. The gridview shows some information. But I would like to remove or disable some columns from the gridview. It is simple in the designer, but I don't know how it works for an class library project(in runtime code). Here is the code I have: gvBoodschapper.DataSource = statsTableAdapter.GetUsersToday().DefaultView; gvBoodschapper.DataBind();  I try something like this, but it doesnt work and gives me errors:gvBoodschapper.DataSource = statsTableAdapter.GetUsersToday().DefaultView; g...

Template column control for gridview
 Hi, I'm trying to create a web server control to use as a template column in a gridview, i want to use the data binded in the gridview as source, so far i haven't been able to do it. Anybody can get me an example of how to do this, or point me the classes i should extend, interfaces i should implement.  Regards,LFonseca  HiWhat exactly you want? HaresHClick here to Visite My SiteIf you want to be successful, be shamelessIf this will not help you out from your problem then please do not Mark As Answer Hi, Lfonseca:You can achieve this by define your ...

Conditional Controls In Gridview Template Column
I have a Gridview which is editable. I want to be able to programatically present the control in the editable field i.e. Display a DropDownList or a custom control instead of a TextBox and this decision is to be made based upon a hidden field in the DataSource. Can this be done and if so how? It can certainly be done. I suggest creating a user control with a TextBox and a DropDownList on it. Only one is made visible through a property of the user control, and both allow reading and writing to a second property (the editable field value). You can bind both properties in the GridView. ...

Creating Dynamic Controls in Gridview Columns
I need a gridview that needs to show information about a product and show information about this product. In the gridview I also want to run a count of how many products there are. To do this I have used an sqldatasource to bind the select information that is about the product and then in the Gridview Databound event i use another sqldatasource to query the Count for each product and then attach to the last column. This all works fine and gets me the results. idont know if it is effecient but it works. I now want the count column to be c...

Dynamically adding column to GridView kills existing template columns
I have a gridview with two template columns that were added at design time.  Each template contains an Item template which just displays the value and an Edit Item template that provides a drop down list during editing.  These columns work fine.  I would like to add a simple display column that is added to (or removed from) the grid when a user checks (or unchecks) a checkbox.  I've done this by adding the following code to my page_load rountine: if (chkAddFieldOffice.Checked)// {BoundField NewField = new BoundField(); NewField.DataField ...

Template column control not Visible in all Gridview rows
I got something odd here.  there is too much code to post, but I have a Template column in a GridView (created in design mode) with a RadioButtonList as the control in that column.  But RadioButtonList does NOT exist in all rows!!!  It shows in some rows.  I am not tinkering with the Visible property.  Oddly enough though, the rows it doesn't show in are the rows with partial data (some dataitems are emptystrings).  But that deosn't make any sense to me.  Anybody seen this before?    jP  I believe you need an e...

how can i place control in GridView Template column
hi i am facing problem placing contrlo on appropriate postion when i placing any web contol in template column it draged up  to header of the GridView can anybody give solution  to this problem thnaks Place it inside the Column tag. <code> <Columns>   <asp:TemplateField>      <ItemTemplate>         [Control here]      </ItemTemplate>   </asp:TemplateField></Columns> </code>Ryan OlshanASPI...

How to manipulate images and combe multiple database columns into one column in a GridView control
Hi Folks,I'm hoping someone can help me out with something.I am trying to put together a photo album as a learning exercise and have a GridView control with two columns linked to an Access Data Source. In the left hand column (called Image) I want to display the photo and in the right hand column (called Details) I want to provide details such as Date, Location, People and Comments, Camera Type etc. Each of these is columns is taken from the database I have set up.However, I have am having some problems:1: At the moment I have been able to get the image to display (using an image column ...

Can Unbound templated controls in a Gridview Update a bound column?
I have a list of stuffed integer words representing several pieces of data. My datasource has two colums - ID and DATAWORD and I want to present the user with a couple of Dropdowns and checkboxes showing the unpacked data for that row. I have done this by populating my unbound controls in the row.databound event  and it works How do I go about Updating the DATAWORD from my unbound controls?  Any pointers to articles that address this would be much appreciated. Thanks   Bill I have a GridView that populates a CSLAObjectDataSource from unbound data.  When the...

Datagrid Dynamic Template Columns with a Data-Driven User Control
All, I am writing a dynamic datagrid that contains X number of columns. The columns are of type Template. Each cell contains a Web user control (which is a database-driven dropdown list). The problem I am having is that when I dynamically create the colum I have to data-bind the dropdown list and apperently it does not it exists. The Web user control works like a champ if I call it directly from another page. This is the error: Object reference not set to an instance of an object. Public Sub Load_List() Line 44: Line 45: Histopathology_Values_List.DataSource =...

how to open new window when click on the dynamic column in gridview control
Hi I am working with Gridview Control with c#.net.from database i am loading 10 columns dynamically on the gridview control.i have to open new widow through javascript when i click on the 8th column.how can i write on click event for the dynamic column in gridview control.your help appreciatable. Thanks in advance        shiva Do you have a hyperlink or button in the 8th column?  And should this happen on each row or the header? Rob Millswww.dotnetadvisor.com...

Binding GridView Columns with controls outside the GridView
HiI already posted this issue but couldn't get the proper resolution so making it more clear;Problem is my controls are outside the grid. Like ive text boxes, for First Name and Last Name and dropdown for country. User can fill these fields for entering a new record and also update the existing by selecting it from the grid.Like user selects a row from the grid and its contents will be displayed on the textboxes and drop downs that are out side the grid.Hope i could explain it better now.  RegardsMohsin Shahzad You could use a DetailsView or FormView control that is linked to the GridView.  This way, you are still updating external from the GridView, but using another *View control that will also link to a DataSource that allows for updating and inserting of records on a one-by-one basis.For more information, look at the QuickStart tutorials for the DetailsView and FormView controls. Christopher Reed"The oxen are slow, but the earth is patient." wolfenstein4u:I already posted this issue but couldn't get the proper resolution so making it more clear;Problem is my controls are outside the grid. Like ive text boxes, for First Name and Last Name and dropdown for country. User can fill these fields for entering a new record and also update the existing by selecting it from the grid.Like user selects a row from the grid and its contents will be displayed on the textboxes and drop downs that are out side the grid. where is your ...

Removing a control dynamically
Hi, I want to dynamically remove a text box control. I have tried: this.Controls.Remove(txtBox); to remove the text box, but it still remains after it is supposed to be gone. I didn't dynamically create this text box with Add. Is that a problem? The text box is also contained in a htmlTable cell. Is txtBox the id of your Textbox control in your <asp:Textbox> element? Where are you placing your code? Page_Load? Try setting the Visible property to False.Jamie Kindred, CGA, MCSD well no, txtBox isn't the id of my textbox control, but I have used ...

Remove controls dynamically!
 I have 4 datagrids on a page and depending on a few parameters leading to that page I want to remove two of them.if(parameter1){     this.Controls.Remove(datagrid3);    this.Controls.Remove(datagrid4);} This piece of code does not seem to work. Whats the proper way to remove a control that was added at design time, during run-time?    Dear Freind, You can't remove the controls added at the design time, if you wants to remove the controls dynamically, then add them dynamically only.  Happy Coding. Mark as a...

Dynamically removing controls
Hi all, My problem is pretty simple: I want to be able to click + and - buttons to add or remove text boxes. Adding works fine but when removing you have to click on the button twice. I've searched around and seen the same issue elsewhere but somehow I'm not quite able to grasp what changes I need to make to my own code. Any help would be greatly appreciated. Here's the aspx file contents:<%@ Page language="c#" Codebehind="AddingDropdowns.aspx.cs" AutoEventWireup="false" Inherits="ARD.Dev.Assets.AddingDropdowns"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >&l...

Removing Dynamic Controls
when i post back and my pages calls LoadViewState(object) and then calls "CreateChildControls" how can i handle removing controls if that value of what control i should remove does not get set in the viewstate until the click event of my button???? which means i wont have the value of the removed control until it post back again....which will leave me with having to click my delete button twice to remove the control from the page...any help on how to firgure this out??Give Yourself a round of applause!DLPDeveloper What you need to do is Get rid of CreateChildC...

How to remove a column from GridView
Hi Friends,  I have a DataTable with 2 columns (ID,  SomeData) that is I am getting from my DataBase, now I want to show in the gridview only two columns (Name, SomeData), Name I am getting from some web service, code is something like this. Button_Click(…..){  Datatable dt;  dt = getMyTable();  dt.Columns.Add("Name", typeof(string));  dt.Columns["Name"].SetOrdinal(1);  myGridView.DataSource = dt;  myGridView.DataBind();} myGridView_RowDataBound(…){              &...

trouble creating a reusable GridView with dynamic Template command Columns VB.NET
I've created a single GridView control that I want to reuse.  My goal is to bind the initial dataset with a programmatically created command column, pass the arguments to a universal RowCommand event handler and dynamically change the DataSource, commandArgument, commandName, and Databind again. I haven't had any success in implementing this idea.  I've tried creating separate template class and Import it, but then I'm unable to assign the properties to the Command column. I just need someone to point me in the right direction.  I've found hundred...

Web resources about - remove a gridview column dynamically, removes controls in template columns - asp.net.presentation-controls

iPhone 5 A6 chip to dynamically up-clock up to 1.3GHz (and downclock too)?
Interesting video from our friends at TLDToday: If this is not just a Geekbench app glitch, it could indicate why that A6 processor is so 2X ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

iPhone 5 Lightning port dynamically reassigns pins
... of Apple's Lightning USB cable shows that the pins on the plug aren't arranged symmetrically, suggesting that the Lightning port can dynamically ...

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 2/15/2016 5:16:17 AM