473,857 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview, TemplateField Programmaticall y.

I want to programmaticall y add a dropdown to each row in a certain
column returned to the gridview by my query. I want to do this
entirely in behind-code. My gridview tag in the page will have the
following code and no more.

<asp:GridView ID="gv" runat="server"
AutoGenerateCol umns="false">

Now, I have generated boundfields to add regular data without a
control to the gridview.

foreach (DataColumn col in tempTable.Colum ns)
BoundField bField = new BoundField();
bField.HtmlEnco de = false;
bField.DataFiel d = col.ColumnName. ToString();
bField.HeaderTe xt = col.ColumnName. ToString();
gv.Columns.Add( bField);

That's fine, but in one of these columns that comes back, I want it to
contain a dropdownlist that could be filled from a separate sql query
and also have this column be editable.

I've referenced http://www.dotnet247.com/247referenc.../13/65435.aspx
and doing such with a dropdownlist, instead of a button doesn't kill
off my page, but it also does not load my dropdownlist.

Any ideas?


Feb 5 '07 #1
0 2263

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Zule | last post by:
Hi, I am creating a Composite Control within which I have a GridView. In this GridView, I have three TemplateFields, the last one being a template with a LinkButton which is meant to be clicked so I can capture this event to do something about it. The problem is that in the CreateChildControls method, I initialize the GridView and link its RowCommand event to a method (so I can capture the LinkButton Click) but it doesn't work... I put...
by: Mike P | last post by:
When you use a SqlDataSource to hook up data to a GridView it seems to be to be very inflexible. For example, I want to create my own Delete button with my own code and I also want to create a popup warning for the user before delete takes place. Whenever I do this with a SqlDataSource, I get the error 'Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified.' Which means I have to specify a sproc or...
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this method has worked for 1 gridview and failed for the second gridview. Here is my gridview : <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XConnectionString %>" SelectCommand="ViewForecast"...
by: Mike P | last post by:
I am trying to edit a gridview while using paging, but whenever I try to edit a row on a page other than page 1, I get an error. Here is my gridview and my code : <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="UserKey" AllowSorting="True" HeaderStyle-Height="24px" AutoGenerateColumns="false" SkinID="Grey3" EditRowStyle-CssClass="dgedit"
by: Philip | last post by:
I can use a GridView and ObjectDataSource to bind my data using "Eval" expressions ... provided the GridView and related Column TemplateFields are defined as inline HTML. I prefer to programmatically create the GridView Column/ TemplateField definitions at runtime.... because I do not know the number of applicable columns until runtime. The addition of the GridView Column/ TemplateFields work fine, however the "Eval" expressions do not...
by: NKaufman | last post by:
<asp:GridView ID="Basic" runat="server" DataKeyNames="QuestionID,isHeading" AutoGenerateColumns="false" AllowPaging="true" PageSize="100"> <Columns> <asp:BoundField Visible="false" DataField="QuestionID" HeaderText="QuestionID"></asp:BoundField> <asp:BoundField DataField="QuestionDesc" HeaderText="Question" ItemStyle-HorizontalAlign="Left"></ asp:BoundField>
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the OnSelectedIndexChanged event set on it. This triggers just fine, but within the codebehind of the OnSelectedIndexChanged event, I need to scan through all the entries in the nested GridView (to see if the user changed a value to an already existing value in the...
by: Danielle | last post by:
All - Thanks in advance for any help you can provide. I've been working with a GridView in Visual Basic for a long time trying to get a list of contacts and to be able to edit and delete the contacts as well as send email on behalf of hte contact. I originally started with the built in update/delete functions of the gridview but I could never get them to work... then I created new pages that are launched on button clicks as shown...
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview with several template columns and a few command button columns, column 1 and 2 are dropdown boxes, column 3 is a checkbox and column 4 is a text box, followed by command button columns. These are all for data entry and although I am populating the dropdown list boxes with an objectdatasource so the user can provide a selection, I am not binding the gridview to anything. The command buttons again are for the user to be...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.