Solved

Dropdown in gridview ASP.NET,VB.NET

Posted on 2013-05-14
1
505 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
1 Comment
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
vb.net and creating a class 5 20
Help with opening combobox using VB.NET. 3 25
VB.net capture  result of a SQL query in variables 3 20
Finding the IIS version 5 21
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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