How do I add Textbox to a dynamic Gridview. Do I need to have a customised Templete Field ? Is there any other way ??
Do you mean you want to dynamically generate rows with TextBoxes in a GridView? If so, then there is a good explanation here:
http://geekswithblogs.net/dotNETvinz/archive/2009/06/04/adding-dynamic-rows-in-gridview-with-textboxes.aspx
Here's one if you're just looking to add a control to a single cell. It's a DropDownList, but could be modified to add a TextBox:
http://www.devasp.net/net/articles/display/708.html
Related
I have a GridView which is completely user defined. The first column of the GridView is from the ListBox1. The headers are defined using ListBox2.
There fore I need to update rows of the GridView with some integer value and make sure the Gridview holds that value until a button is clicked.
Once the button is clicked I want to read each columns of the GridView that has values entered and create a table in the database with the headers names as columns and just replicate the GridView as table in database.
I have attached a screenshot of my GridView. Kindly help me fix this problem.
There are 2 key things to implement UPDATE logic in a GridView
In the GridView markup, you have to add an eventhandler for OnRowUpdating event
<asp:GridView ID="XXX" runat="Server" .....
OnRowUpdating="UpdateRecord" ..........>
Then you need to implement this "UpdateRecord" method referred above with your custom code which will basically retrieve the data from the grid row and update it to your datasource
You can refer to some sample code of how this can be achieved here
To point out again, in your case, since you want to dynamically create the table as well, you will need to additionally do that as well. Personally, i have no clue why you would go with such a design but in absence of any information, i assume you know best.
I have a textbox named textbox1 and a dropdownlist. Dropdownlist contains the list of branches and i want that when i select a branch from dropdown i want to get the respective branch code to be generated in a textbox from the Database or from c# coding. How will it be possible ?
Am I missing something, is it more complex that just putting an event handler on the dropdown so that when it's value changes it calls your method that can do whatever it needs to do to generate the string for the textbox?
Skipping passed the "database" portion of your question (and assuming your data isn't bound to the DropDownList)..
One way in ASP.NET, to accomplish this, I believe, is to have your code print DropDownList.SelectedValue's value in the textbox during an event.
Here is a link showing how to bind an event to DropDownList in jQuery
I have a repeater that has a text box and when I enter edit mode on my repeater, I want to replace the text box with a dropdownlist of available options. Is there a way to remove the text box upon item databind and replace it with a dropdownlist for the selected rows index.
Use whatever you are using to indicate edit mode and edit index in the OnItemDataBound event. Then the easiest way is to just hide the text box and show the dropdownlist instead. Whether this works for you or not is dependent on what you're trying to do.
I want to add DomainUpDown control inside a DataGridView as a separate column. Each time a new row is added, I want that DomainUpDown control also be added. I also want to know when the user click the DomainUp or DomainDown button in DomainUpDown control for each row. Is it possible or not? I am using language vb.net/C#. I want to do this in winform not in ASP. Any help or suggestion please!!!
All you need to do/know is how to add an unbound column to an already data bound DataGridView, because from your description you are trying to add a column to a grid which already contains other data bound columns. In fact it would be easier if you had such column in the DataTable, also because with unbound columns you need to make a slightly bigger effort to populate and save the data from/to somewhere.
anyway it should be possible, MSDN explains it here: How to: Add an Unbound Column to a Data-Bound Windows Forms DataGridView Control
I have a gridview that I wish to display gridlines only on certain rows.
I want them to be on each column, but only after every 4 rows. Is this possible?
Thanks.
You can use the DataGridView.CellPainting event.
You can always user javascript (JQuery) to select wanted columns on table generated by gridview asp.net. After selecting this columns, set their right-border to wanted value or color.
If you don't want to use javascript, you can use RowDataBound eventHandler. If your columns are template fields, you can find wanted control ( e.Row.FindControl("ControlName")) and it's parent ( e.Row.FindControl("ControlName").Parent ). I am not sure, but I think that parent should be wanted cell and then you can set borders. You can try something like this, I haven't tried this.