?
Solved

Dropdown in gridview ASP.NET,VB.NET

Posted on 2013-05-14
1
Medium Priority
?
511 Views
Last Modified: 2013-05-15
I have a gridview in one of my aspx pages in which I want one column to be dropdown and one other to be a check box and rest to be text boxes. So when the gridview loads all the columns are read only but when the user hits edit button first column needs to be a dropdown with the the values in it being populated from a table in the database. second column needs to be checkbox. rest as textboxes.

Here is how I have created my gridview in the aspx.
<asp:GridView ID="GridView1" AutoGenerateColumns="true" AllowPaging="true" AllowSorting="true"  
            onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
                runat="server" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
                Width="317px">
                <PagerSettings Position="Top" Mode="NumericFirstLast" />
                <PagerStyle HorizontalAlign="Right" VerticalAlign="Middle" BackColor="#ECF0FC" />
                <FooterStyle BackColor="#CCCCCC" />
                <HeaderStyle BackColor="#284E98" ForeColor="White" Font-Bold="True" />
                <EditRowStyle Wrap="False" />
                <AlternatingRowStyle BackColor="#F6F1D4" BorderColor="Black" />
            </asp:GridView>


Code Behind to populate the gridview:
 Dim cmdList As DbCommand = m_database.GetStoredProcCommand("storeproc_name")

Dim listDS As DataSet = m_database.ExecuteDataSet(cmdList)
            Dim iNoOfRowsReturend As Integer = listDS.Tables(0).Rows.Count
            ShowSearchMessage(iNoOfRowsReturend)

            GridView1.DataSource = listDS
            GridView1.DataBind()



Can someone please help me with this.

Thanks
0
Comment
Question by:pratikshahse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 39164596
Turn off auto generate columns.

For most of the fields you can get away with a bound column if you're just using the default textboxes.

For your field in question, you're going to want a template column with an itemtemplate that has a label and an edititemtemplate that has a dropdowlist.

Here is some sample code:
http://www.dotnetfunda.com/articles/article29.aspx
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question