Datagrid Control, template columns

Hi all i am working on datagrid control. I have to columns both are template columns.The first template column contains a textbox control, the second column contains a dropdownlist. I need to bind the data to the first column fileupload control and the dropdownlist should be populated from the database. How do i go about doing this please help me.

7/21/2008 10:12:31 AM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 24


If u want to Bind Text Box From Data Base then Bind TextBox Template as like below

                                                        <asp:TextBox ID="txt" runat="server" Text='<%# eval("database fieldname") %>'></asp:TextBox>

And U want To Bind DropDown Then write following code into gridview rowdatabound event

 Dim ddlTest As New DropDownList

If e.Row.RowType = DataControlRowType.DataRow Then
            ddlTest = CType(e.Row.FindControl("ddlTest"), DropDownList)

           -----------------Here Fetch DataSet Or Value Which You Want To Bind To DropDownList And Then Assing as like below--------





        End If


~ Mark As Answer If UseFull ~


~ Mark As Answer If UseFull ~

7/21/2008 12:05:28 PM

I have tried the above using ItemDataboung event of the datagrid control. This event occurs for each of the row that is geeting binded to the grid.. But i need my requirment is the.. When i choose a file using the fileupload control and when and External event(button click) occurs the datagrid should be populated with one row having the file name and the dropdownlist from the datasource. How do i go about doing this


7/21/2008 1:14:51 PM


Still I am not getting your actual problem and what you want...

if posble paste your code then i will go further for your problem and solve out it.


~ Mark As Answer If UseFull ~

7/22/2008 6:27:02 AM

Hi Geetha ,

Try my sample,


        protected void Button1_Click(object sender, EventArgs e)
            HttpFileCollection uploads = HttpContext.Current.Request.Files;
            for (int i = 0; i < uploads.Count; i++)
                HttpPostedFile upload = uploads[i];

                if (upload.ContentLength == 0)

                string c = System.IO.Path.GetFileName(upload.FileName); // We don't need the path, just the name.

                DataTable table = new DataTable();
                DataRow dr = table.NewRow();
                dr["filename"] = c;

                this.GridView1.DataSource = table;

                //    upload.SaveAs("C:\\UploadedUserFiles\\" + c);
                //    Span1.InnerHtml = "Upload(s) Successful.";
                //catch (Exception Exp)
                //    Span1.InnerHtml = "Upload(s) FAILED.";

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                DropDownList ddl = e.Row.FindControl("DropDownList1") as DropDownList;
                //set ddl's datasource here !!!
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("filename") %>'></asp:TextBox>
                    <asp:DropDownList ID="DropDownList1" runat="server">
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    <asp:FileUpload ID="FileUpload1" runat="server" />



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.
7/23/2008 4:40:19 AM

Similar Artilces:

How to place a DataGrid Control with in a DataGrid Control
Hi, I want to place a DataGrid control in a DataGrid control can any one plz tell me the procedure to place the control Thanks in Advance Krisamigo <!---<asp:DataGrid ID=dg_List runat=server><Columns><asp:TemplateColumn><ItemTemplate><asp:DataGrid ID=dg_List2 Runat=server></asp:DataGrid> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> ---> Hardik Joshi...

How to access a template column in a datagrid control
I have a DataGrid control on a web form with a template column. How can I access the dropdownlist column "ddlusertype" from my c# code? I need to bind it with a DataTable. Please help, thanks! Here is my code <Columns> <asp:BoundColumn DataField="rolName" HeaderText="User Type"></asp:BoundColumn> <asp:BoundColumn DataField="rolDescription" HeaderText="Description"></asp:BoundColumn> <asp:BoundColumn DataField="gtyAbbr" HeaderText="Client Type"></asp:B...

Inherited controls in datagrid template columns
Hi all,I have created inherited HyperLink control as follows Public Class ResourceHyperLink        Inherits HyperLink        Private m_ResourceID As Integer        Private m_ResouceName As String        Public Property ResourceName() As String            Get                ResourceName = m_ResouceName    &...

Finding a template column control in a datagrid
I have read several articles on finding a control in a datagrid.   the problem I am having is in the code "datagrid1.selectedindex+ always returns "-1"   Here is my code behind: Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand Dim iEntryID As Integer Select Case e.CommandName Case "chkIPTC" iEntryID = CType(e.CommandArgument.ToString, Integer) 'TO DO: Write code to get IPTC data from database or picture? Dim txtIPTC As TextBox = CType(DataGrid1.Items(DataGrid1.Select...

Hello, I was wondering if it is possible to add a DropDownList control within a DataGrid control? Here's what I'm trying to do...I have one column in the DataGrid that I wish to allow the user sto select one of two options.I wish to do this by providing a DropDownList control within the <columns> tag of the DataGrid. I figured I could use a TemplateColumn control and within that add the DropDownList.I found out that does not work (not allowed). I also tried to get creative and add a script "block" within the TemplateColumn, but that did not work ei...

Adding Template Column with web controls to datagrid
I want to add Web controls for e.g. textboxes,checkboxes,radio buttons etc to template column which has to be created at run time. i am able to use external user web controls(.ascx) using a itemplate.loadcontrol method. what about web controls(e.g. text boxes etc)? Hello, you can check this example, which shows how to edit a Datagrid, inside it there are places where they put server-contols, check both articles please: 1- Editing DataGrid 2- Adding Template Columns to a DataGrid Control regardsBilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

Using a templated control inside a databound templated control
Hi,  We have a large number of pages that display contents in a simple header - content combination. To facilitate styling, we have created a custom control 'ContentArea' that exposes two template properties: HeaderTemplate and ContentTemplate. These allow a designer to define the layout for the header and content in the aspx file. In addition, two themable properties named HeaderCssClass and ContentCssClass allow the definition of a Css class for both texts. Like this, using theming, defining the style of our site contents becomes extremely simple. As an exampl...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Control No of records in DataGrid control
Hi I am having more than 5000 records in the table. I had set page size:50, its loading 5000 records and showing 50 records... working fine. But my requirement is when page is loading i need to get only 50 letest records from the database. If user clicks on next it need to be connected to database and get next 50 records. How i can put pointer at 50 th record? Is there any way to do this???... plz help Top function wont work for me. Hope the problem is clear regards cnu The SQLDataAdapter can limit the rowsets in one of the Fill() method overloads. Check it out in the ...

datagrid control in to Tabstrip control .
i need to insert a datagrid in a tabstrip seperator. is this possible? and in what way . Do you really mean Tabstrip "Seperator"? Or are you just trying to insert a DataGrid into a TabStrip control? ...

Referencing a control in a Template control
I have a DetailsView in which one of the Fields is a TemplateField control, and this has an EditItemTemplate which contains a DropDownList. How do I reference that DropDownList from my code behind?  I tried DetailsView1.FindControl("xxx") but it didn't work. Thanks.  hc1   hc1: I tried DetailsView1.FindControl("xxx") but it didn't work.To reference a control that is placed in the EditItemTemplate of the detailsView, the DetailsView must be in Edit  Mode ( CurrentMode=Edit )so you need to check the detaildview mode before trying to access ...

How can I register an event for a control in DataGrid template column?
Hello Is it possible to register events for controls in a DataGrid template column? I have an editable DataGrid comprised mostly of template columns. I want to use a CustomValidator for some of the columns but I don't know how to register events for the CustomValidator. In particular I want to wire up a 'ServerValidate' event. When I use a CustomValidator (or any Control for that matter) outside of a DataGrid control, I have access to the Events tab in the Properties window. But when the Control is in a Template column of a DataGrid, the Events tab is not there anymore. Is it poss...

problem with User Control position in DataGrid template column
I have a data bound user control, which includes an Image button and a label it all works fine but in the DataGrid it only appears in the first cell.As the DataGrid is populated the image button seems to load the correct number of times for the rows but does not go down the page just loads on top of its self. I am using an external style sheet to control the label display properties I believe it is due to the position which is set as Absolute for the button and label to keep the label on top of the image and I guess what I want to do is set the position attribute to relative for the c...

Problem with hyperlink control when used in DataGrid in a templated column
Hi All, Can someone help me solve this problem. I ama beginner to ASP.NET and I am just trying out various samples. Mentioned below is a very simple program of getting data to grid with one of the column as a Bound Hyperlink control. I guess you are pretty busy. I had to sent you a quest earlier regarding loading the data from database to an XML file. I posted the question in yur blogs. Anyway I have another question with the datagrid control. Here it is : I have the foll. Situation in my sample test program : I have a single DataGrid control in an ASP.NET page ...

Web resources about - Datagrid Control, template columns -

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 12/4/2015 2:25:44 AM