I am having one DataGrid..I want to create one button field inside the DataGrid dynamically.
Button filed type is link type.. this button field is fill after checking some conditions in my database..any body help me
Maybe use Jquery to add some controls or you can use httpwriter
httpwriter msdn
The answer for this may require you do a tiny bit of reading/understanding.
Basically you do two things:
1) Add the button design-time and 2) choose its visibility based on database condition.
Related
I'm using RadGridview and its FooterRow contains 3 Check Boxes.Now if i want to allow only one checkbox to be checked and the other two should not be allowed to check how should I implement it? i need to implement.
Like the Radio buttons.
Since you can have any controls in a FooterRow, can you not actually use Radio Buttons rather than checkboxes?
If you have a situation where you want to have a checkbox at the foot of each column and only one of those checkboxes can be selected, you probably need to provide a little more information about the intent you are trying to accomplish.
What is the difference between command field and template field in grid view and how can I use them in grid view?
I am new in c# so please provide full help so I can feel easy to work with both.
thanks
A CommandField enables to display command buttons to perform selecting, editing, inserting, or deleting operations in a data-bound control.
A TemplateField enables to display custom content in a data-bound control. You could for example nest another GridView inside it or a custom WebUserControl which consists of several other controls.
So in short:
a CommandField autogenerates a button or link for special actions like edit/delete
a TemplateField is extremely customizable, you can put anything there
Template fields are fields where you add controls inside gridview columns.
And command fields are the attribute through which you came to know which control has generated event inside girdview.
In template field you can place any asp.net control, you can customize it.
From MSDN:
Represents a field that displays custom content in a data-bound control.
Command Field:
From MSDN:
Represents a special field that displays command buttons to perform selecting, editing, inserting, or deleting operations in a data-bound control.
Templete Field :- If U Want To do Some More Action in GridView Like Editing , Display Images etc Then U Hav To Use Templete Filed.
In my page, i got two column and multiple rows. The first column contain the label such as question for the 1st row, and the options for the questions. And the second column is the textboxes. When i click on add button, i wish to add those controls to page which subsequently allowed me to add the value in the texbox to database. I did some research but most of them uses javascript or datatable. Is there any other method?
You don't specifically say what type of .net development you are doing, and your question is tagged with asp-classic, which I doubt you're using. [If you are please please stop] So I will assume you are using Web Forms.
While I don't agree with Inerdial's position that you should avoid dynamic controls at all costs, I will say it does make things much more complex and requires a very good knowledge of the ASP.net Lifecycle. If you truly want to go down that path, here is a great resource.
With that said what you are describing to me does not appear to need that and his suggestion of setting the control visibility to false is a good one.
You could create a row, a panel or a div and output the controls that you need when adding a new row and set it's server-side visibility to false whenever you don't want it displayed. Then you could have a link that when clicked it toggles the visibility to true and will allow the user to add items. Once users add items they'll be displayed in your data table and you can reuse the form to add additional items.
I would also like to encourage you to consider JavaScript if it isn't an overly complex form. It eliminates an extra round-trip to your server and in general is a better user experience.
Edit: This link may also be of use to you.
I have requirement in my application where I am struck . These is my scenario:
Initially I need to show up two text boxes with a check box and a button. upon clicking the button we need to generate one more row. Like wise we need to create multiple rows dynamically.
Initially I tried with Table Control but after struggling a lot, I came to know that we can create only one row dynamically using Table Control. So now I am planning to do in repeater control.
In this kind of scenario, it would be better to use the GridView Control Instead, take a look here some working examples:
http://www.revenmerchantservices.com/page/gridview-add-new-row.aspx
http://amitpatriwala.wordpress.com/2008/04/18/inserting-new-row-in-gridview-in-aspnet-20/
Add dynamically controls to asp placeholder in addition to controls which already exist in it ?
how to add them?
for example - on page load I added to textboxs and labels to placeholder on button click I need to add additionally one more textbox.
you can use the methods like Add, AddAt, Remove, RemoveAt, Clear to change the controls collection available on the PlaceHolder control.
Check this link for an elaborate explaination of the methods mentioned above.