|
|
DropDownList Inside GridView (Method 1)
AzamSharp
Published Date: 3/26/2006 6:55:43 PM
Views: 144687
Abstract:
In one of my previous articles I explained that how you can embed a DropDownList inside the GridView control. You can check out the article at Accessing DropDownList inside the GridView Control. If you look closely you will notice that all the DropDownList inside the GridView contains the same information. In this article I will demonstrate that how you can have DropDownList inside the GridView exposing different information.
Introduction:
In one of my previous articles I explained that
how you can embed a DropDownList inside the GridView control. You can check out
the article at
Accessing
DropDownList inside the GridView Control. If you look closely you will
notice that all the DropDownList inside the GridView contains the same
information. In this article I will demonstrate that how you can have
DropDownList inside the GridView exposing different information.
Analysis:
There are couple of ways in which you can
achieve this task. In this article I will demonstrate the approach of using
DataSet to populate the DropDownList inside the GridView. Take a look at the
screen shot below so, you will have a clear idea of what you will be learning in
this article.

As, you can see in the above image that each
DropDownList is different and is populated on the basis of the category type.
Now, let's see the code.
The first thing that you need to do is to
populate the GridView so that it will have CategoryID and CategoryName. These
are the first two columns of the GridView.
|
private
DataSet
GetDataSet() {
string
query =
@"SELECT p.CategoryID,p.ProductID, p.ProductName
FROM Products p
SELECT c.CategoryID,c.CategoryName FROM
Categories c";
string
connectionString = @"Server=localhost;Database=Northwind;Trusted_Connection=true";
SqlConnection myConnection =
new
SqlConnection(connectionString);
SqlDataAdapter ad =
new
SqlDataAdapter(query,
myConnection);
DataSet
ds = new
DataSet();
ad.Fill(ds);
return
ds;
} |
Since, the query consists of two SELECT
statements it means that it will return two tables. The table that I am
interested in is the Table[1] which contains the result of (SELECT
c.CategoryID,c.CategoryName FROM Categories c").
In the Page_Load event you can bind the DataTable to the GridView using the code
below:
|
protected
void Page_Load(object
sender, EventArgs
e) {
if
(!Page.IsPostBack)
{
// This is
because Table[1] contains Categories
GridView1.DataSource = GetDataSet().Tables[1];
GridView1.DataBind();
}
} |
If you run your application now then you will
see that your GridView consists of the CategoryID and CategoryName columns but
no GridView column. Keep in mind that CategoryID and CategoryName are bound
columns.
Add a simple template column to the GridView
and place a DropDownList inside the template column. Here is the HTML code for
the GridView control.
| <asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField
DataField="CategoryID"
HeaderText="CategoryID"
/>
<asp:BoundField
DataField="CategoryName"
HeaderText="Category
Name"
/>
<asp:TemplateField
HeaderText="Products">
<ItemTemplate>
<asp:DropDownList
ID="DropDownList1"
runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView> |
Populating the DropDownList:
Now, it is time to populate the DropDownList
control. I used the GridView_RowDataBound event to populate the DropDownList.
Take a look at the method below:
|
protected
void
GridView1_RowDataBound(object
sender, GridViewRowEventArgs
e) {
DataTable
myTable = new
DataTable();
DataColumn
productIDColumn = new
DataColumn("ProductID");
DataColumn
productNameColumn = new
DataColumn("ProductName");
myTable.Columns.Add(productIDColumn);
myTable.Columns.Add(productNameColumn);
DataSet
ds = new
DataSet();
ds = GetDataSet();
int
categoryID = 0;
string
expression = String.Empty;
if
(e.Row.RowType == DataControlRowType.DataRow)
{
categoryID =
Int32.Parse(e.Row.Cells[0].Text);
expression =
"CategoryID = "
+ categoryID;
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
DataRow[]
rows = ds.Tables[0].Select(expression);
foreach
(DataRow row
in
rows)
{
DataRow
newRow = myTable.NewRow();
newRow["ProductID"]
= row["ProductID"];
newRow["ProductName"]
= row["ProductName"];
myTable.Rows.Add(newRow);
}
ddl.DataSource = myTable;
ddl.DataTextField =
"ProductName";
ddl.DataValueField =
"ProductID";
ddl.DataBind();
}
} |
Explanation of the code:
The first thing I did is to create a DataTable
which will contain the ProductID and the ProductName.
|
DataTable myTable =
new
DataTable();
DataColumn
productIDColumn = new
DataColumn("ProductID");
DataColumn
productNameColumn = new
DataColumn("ProductName");
myTable.Columns.Add(productIDColumn);
myTable.Columns.Add(productNameColumn); |
After creating the DataTable I get the DataSet
using the GetDataSet method.
|
DataSet ds =
new
DataSet();
ds = GetDataSet(); |
The GridView already contains the CategoryID
and CategoryName data since I populated it inside the Page_Load event. On that
basis I retrieve the CategoryID from the GridView and generate an expression.
| categoryID =
Int32.Parse(e.Row.Cells[0].Text);
expression =
"CategoryID = "
+ categoryID; |
The expression is used on Table[0] and acts as
a criteria on the Products table.
| DataRow[]
rows = ds.Tables[0].Select(expression); |
Now, all the products associated with the
particular category are inside the DataRow array. I parse through the
array and populate the DataTable I created earlier.
|
foreach (DataRow
row in
rows) {
DataRow
newRow = myTable.NewRow();
newRow["ProductID"]
= row["ProductID"];
newRow["ProductName"]
= row["ProductName"];
myTable.Rows.Add(newRow);
} |
After the DataTable is populated I simply
assign it to the DropDownList.
| ddl.DataSource =
myTable; ddl.DataTextField =
"ProductName";
ddl.DataValueField =
"ProductID";
ddl.DataBind(); |
Conclusion:
After the GridViewRow is databound you will
notice that each of the template column contains a DropDownList which displays
information related to a particular category. In this article you learnt that
how you can create as well as display one to many relationships inside the
GridView control using DropDownLists.
I hope you liked the article, happy coding!
Comments/Feedbacks
|
|
|
|
Subject: Hi to all gridviewguys
Name: sudhakar
Date: 1/24/2007 1:07:51 AM
Comment: This article is very nice, but i want insert the check box at heaer of the grid view table when i select that check box all the reamning check boxes in that check box column will be selected.
This is my criteria please forword the links appropriate this one
Thank u. |
|
|
|
|
|
Subject: RE:
Name: AzamSharp
Date: 1/24/2007 9:00:39 AM
Comment: Hi Sudhakar,
Yes, you can easily do this. Check out my article using the following link:
http://gridviewguy.com/ArticleDetails.aspx?articleID=228
|
|
|
|
|
|
Subject: Grid View in asp.net 2.0
Name: neeraj kumar
Date: 2/6/2007 11:47:01 PM
Comment: It's very nice example to understand the GridView server control. |
|
|
|
|
|
Subject: new row
Name: asp.net novice
Date: 2/8/2007 3:54:48 PM
Comment: Is it possible to move the drop down menu for each category to a new row beneath the category? |
|
|
|
|
|
Subject: Request for code
Name: Ramya
Date: 2/8/2007 11:45:21 PM
Comment: Hi
I am having a grid for tht i have added a column in tht column i have taken another grid . in tht grid i have taken 2 link buttons.
My requirement is when i click on any of the linkbutton i have to get the selected row col1 value so tht i can use tht value. Does anyone help in this task.I have a solution mail to me |
|
|
|
|
|
Subject: gridview
Name: Sameer Ali Khan
Date: 2/14/2007 8:34:49 PM
Comment: Dear Azam!
Its very nice and helpful code.Many of my issues are resolved.
Keep it up. |
|
|
|
|
|
Subject: Superb
Name: Himanshu Sharma
Date: 2/16/2007 2:52:31 AM
Comment: Hi,
Really really....... this is very helpful.
Thanks a lot |
|
|
|
|
|
Subject: Can you this also in vb.net?
Name: gerbrand
Date: 3/22/2007 6:24:18 AM
Comment: Hi, i just wanted to know if this is also possible in vb.net... I tried it, but nothing worked...
if someone can help me with this.
Thanks |
|
|
|
|
|
Subject: update gridview with ddl
Name: nico
Date: 4/10/2007 11:44:14 AM
Comment: can you use this list to update the row?
do you have an example for that
thank you
|
|
|
|
|
|
Subject: RE: Update GridView With DDL
Name: AzamSharp
Date: 4/12/2007 1:10:03 PM
Comment: I would be glad to help you. Can you provide more details? |
|
|
|
|
|
Subject: Selected value of dropdown list
Name: Benjamin Legaspi
Date: 4/19/2007 11:07:39 AM
Comment: Say you have a gridview of employees and the last column is a dropdown list consisting of job titles (e.g., programmer, manager, secretary). You populate the gridview using data from a table and want the appropriate title to display on Page_Load. Can you do this? I'm using VB and can only get the dropdown to display the first item for all the rows. Thanks for any advice. |
|
|
|
|
|
Subject: study
Name: gajendrasingh
Date: 5/2/2007 9:19:37 PM
Comment: dear sir,
please give me some examples in c#.NET GRIDVIEW(EVENT EDIT,DELETE,UPDATE).
THANKING YOU |
|
|
|
|
|
Subject: I worked it on a Grid View Edit Template
Name: Nitin
Date: 5/3/2007 4:05:37 PM
Comment: Well you really gave me an idea. Thanks |
|
|
|
|
|
Subject: Nice JOB
Name: Prasad
Date: 5/4/2007 8:59:02 AM
Comment: Hi buddy
Gud JOB.
Keep it UP.
|
|
|
|
|
|
Subject: getting values from the dropdownlist
Name: guna
Date: 5/6/2007 8:07:16 AM
Comment: hi guys
The article is good, but i want to get the values of dropdownlist which i have have placed in griedview
after selecting the values from the dropdownlist then i have to fill another dropdownlist based on the first dropdownlist vales
both the dropdownlists are placed on the grid viwe control.
please help me. |
|
|
|
|
|
Subject: gridview with two table
Name: prashant
Date: 5/12/2007 2:10:46 AM
Comment: This is a very good example of gridview that binding two table data in one single gridview.
This is a very good example of programming.
many many
Thankssssssssss |
|
|
|
|
|
Subject: Help with DropDowns
Name: RobertM
Date: 5/17/2007 8:48:03 AM
Comment: Thanks for the above code but I think I need a little more direction.
Alright I have almost got this application finished but I am totally stuck and have been stuck for the last several days so I think that I now need some more help. To review this is what I have. I have two tables one named oncall and one named mainphonelist. The oncall table displays the information in a datagrid view and consists of the following fields:
Application - Primary Key
Name
Cell
Pager
Office
Comment
The MainPhonelist is the pool of all possible people who can be on call and it contains the following fields:
Name
Cell
Pager
Office
What I have done so far is create the gridview that shows all the data in the oncall table. When edit is clicked a dropdownlist is presented to the user containing all possible people from the mainphonelist.
Now here is the issue. I want the cell, pager, and office fields to update when the user selects a name from the drop down list with the corresponding information for that name. So for example, If I select John Doe from the list I would like to populate the cell, pager, and office fields with John Doe's information from the mainphonelist.
I know the program code needs to go into the DropDownList1_SelectedIndexChanged sub but I don't know what code I would use. I have tried the gridview1.selectedrows.cells(2).text object but I can't update it because it is readonly.
All Help is appreciated. |
|
|
|
|
|
Subject: Help Required
Name: Arsalan
Date: 5/31/2007 10:12:05 PM
Comment: Hi,
I have a ddl in a grid view edit item template . I bind the ddl on gridview row data bound event.Now i am not able to get the newly selected value of ddl in my update function.
Any ideas how to achieve this?
Thanks! |
|
|
|
|
|
Subject: Updating
Name: Nuke
Date: 6/4/2007 9:09:15 AM
Comment: Can you provide code on how to update the database once one of the dropdown has been changed? |
|
|
|
|
|
Subject: dropdown list view in editmode
Name: Rehan Wahab
Date: 6/13/2007 5:00:33 AM
Comment: Very nice example.
kindly send me any one example above subject.
Thanx |
|
|
|
|
|
Subject: ListBox in Datagrid
Name: priya.K
Date: 6/15/2007 4:28:42 AM
Comment: Instead of Grid view control i used Datagrid.while populating the data into the listbox i got the error as "Object reference not set to an instance of the object"
kindly tell me the sollution
"IT IS VERY URGENT"
|
|
|
|
|
|
Subject: Why is this so hard?
Name: Walter
Date: 6/18/2007 9:44:29 AM
Comment: WHY is it so hard to do this? Even with this superb example, the built in controls still wont do what I want them to do.
All I want is to display in my grid with a dropdown control. That control should BIND to a field in a table and offer VALUES FROM WHICH TO SELECT from another table. Why doesnt the people working on ASP.Net talk to the Access people. Access got it right, why doesnt ASP.NET??? |
|
|
|
|
|
Subject: Hi..
Name: Durga Prasad
Date: 6/19/2007 4:08:09 AM
Comment: I think more explanation is required to understand the code. |
|
|
|
|
|
Subject: Binding the Selected value
Name: Neil
Date: 6/19/2007 7:45:55 AM
Comment: I have the dropdown lists being populated correctly but what I need to know is how do I bind the SelectedValue?
When I add SelectedValue='<%# Bind("TestRequestId") %>' to the dropdownlist markup I get an "Object reference not set to an instance of an object" runtime error
Help would be gratefully appreciated |
|
|
|
|
|
Subject: gridview
Name: sura
Date: 7/5/2007 6:53:39 AM
Comment: the article is very useful, but I wonder if you could give more detailed information about rowdatabound event method part.
thank you.. |
|
|
|
|
|
Subject: RE: GridView
Name: AzamSharp
Date: 7/5/2007 5:29:04 PM
Comment: Hi,
Let me know what details you need for the GridView_RowDataBound event. |
|
|
|
|
|
Subject: comments
Name: sandeeppathania
Date: 7/9/2007 4:37:09 AM
Comment: this article is really brilliant |
|
|
|
|
|
Subject: How to insert
Name: siva
Date: 8/26/2007 11:53:04 PM
Comment: Hi Azam,
Upto now it is so clear. can you tell how to insert the dropdownlist selected value into the database.If you do that i hope that is great help full for users
Thanks
Siva.. |
|
|
|
|
|
Subject: Question
Name: A J
Date: 9/3/2007 2:35:20 AM
Comment: Hi Its a nice article but i have a label in item template and dropdown in edititemtemplate and this doesnt seem to work there.
It would be nice if u can send an example for the same.
More over i am not using datasource control but instead using a table.
So kindly reply asap.
Thanks |
|
|
|
|
|
Subject: Great Explanation
Name: bhagyavathy
Date: 9/12/2007 4:58:19 AM
Comment: Hi,
The article was very useful and it helped me a lot to solve my problem.
Thank you |
|
|
|
|
|
Subject: how to get values
Name: Khushi
Date: 10/3/2007 9:08:52 AM
Comment: Now after adding I want to retreive the value selected from drop down list ..how do I do it
Thanks |
|
|
|
|
|
Subject: Advice on how to update using dropdown data
Name: Joel
Date: 10/4/2007 10:40:39 AM
Comment: Many of you have asked how to use the value of a dropdown box to update the database. I just went through this so I'll explain what I did.
I used an editItemTemplate to add the dropdown which had it's own data source. Then I added code to the RowUpdating event to get the data into the right grid data field for updating.
editItemTemplate:
Code behind:
Private Sub gvOverrides_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvOverrides.RowUpdating
Dim DropDownPeriods As DropDownList = CType(gvOverrides.Rows(e.RowIndex).FindControl("ddPeriods"), DropDownList)
e.NewValues.Item("period_id") = DropDownPeriods.SelectedValue
End Sub
Hopefully that helps some of you out!
|
|
|
|
|
|
Subject: Feedback
Name: krishna
Date: 10/9/2007 10:16:27 PM
Comment: Its very usefull for me. Very good site for beginners and experts. |
|
|
|
|
|
Subject: Datagrid add column
Name: Patrick
Date: 10/22/2007 12:56:06 PM
Comment: I'm trying to add a column in a datagrid on the aspx page in C# I have:
trying to add linkbutton to concatenate ID and name.
currently it is written as a button column and dynamically two string are added to e.item.Cells[2]. I tried to use
linkbutton
but errors on page.
If you need more information please email me for the code. |
|
|
|
|
|
Subject: DDL in GridViews
Name: Jody
Date: 11/13/2007 8:41:10 AM
Comment: Thanks for the example and detailed explination, it was a huge help!! |
|
|
|
|
|
Subject: RE: DDL in GridViews
Name: AzamSharp
Date: 11/13/2007 12:50:06 PM
Comment: I am glad you liked the article! |
|
|
|
|
|
Subject: Dropdown selection
Name: Anup
Date: 11/27/2007 11:14:15 AM
Comment: Hi,
This artical really helped me a lot.
But i got stuck in last.
When i am selecting any value from the dropdown, I want row index of grid or the value of the first column for that perticular row in DropDownList2_SelectedIndexChanged.
Pl. let me know if some body know the way out.
Thanks
|
|
|
|
|
|
Subject: RE: DropDownList Selection
Name: AzamSharp
Date: 11/27/2007 12:50:36 PM
Comment: Hi Anup,
Check out the following video:
http://www.koffeekoder.com/ArticleDetails.aspx?id=341
|
|
|
|
|
|
Subject: Query
Name: kumar
Date: 12/6/2007 8:36:24 PM
Comment: Dear Sir ,
I have gone thru ur "to add a column in a datagrid " But I hav got a problem here . In my grid thr r 20 fields
i jus wanna knw how break the total columns in to 2 parts and i wanna show them in paging can u please suggest me .
the previous one is very nice and tried it too.
thank you. |
|
|
|
|
|
Subject: postback problem
Name: sad
Date: 12/12/2007 3:09:47 PM
Comment: Thanks for the Article, I have followed the same. But on post back, it resets all dropdown to first item. It is not keeping what I have selected even I enable view state. Any workaround on it? |
|
|
|
|
|
Subject: RE: Postback problem
Name: AzamSharp
Date: 12/16/2007 4:08:15 PM
Comment: Hi Sad,
Make sure you are only populating the DropDownList inside the if(!Page.IsPostback)
{
// populate the //dropdownlist
} |
|
|
|
|
|
Subject: GridView dynamic dropdownlist column binding
Name: gridview
Date: 12/23/2007 10:51:55 AM
Comment: first of, the site is very informative and thanks for the same. I am using CridView control in my application. Here, I would like to display 3 columns in the Grid View. I do not attach any dataset to GridView control. I would like to add rows manually using "add row" button. When I say, add row, only first column of the row will be displayed. This is a dropdown list and based on the selection (e.g. size) in the dropdownlist, the second column populates a dropdownlist. Based on selection in the dropdown list the third column populates. This third column can be TextBox, CalenderControl or dropdownlist.
I am using GridView Control for this. But I am not sure about how can I make the columns visible and invisible at runtime. Could you please suggest? thanks |
|
|
|
|
|
Subject: GridView
Name: pradeep
Date: 1/29/2008 4:09:07 AM
Comment: Very Nice Article keep it up
Thanks a lot
Regards
Pradeep |
|
|
|
|
|
Subject: Thanks
Name: Raxi
Date: 2/5/2008 1:14:43 PM
Comment: Thanks GridviewGuy... Keep posting such articles. I tried with radiobuttonlist instead of dropdownlist and it worked. Thanks |
|
|
|
|
|
Subject: Use ODS is easier?
Name: Stevishere
Date: 2/10/2008 4:16:42 AM
Comment: Hi Azam,
I really appreciate your articles. I reference them quite often.
For this particualr scenario, it seems it would be much less code and simpler to simply use an Object Data Source in the Gridview Template. If it is desired to update the Selected Value that can be dome with the SelectedValue='<%# Bind("MyID") %>' context.
Am I overlooking something? |
|
|
|
|
|
Subject: RE: Use ODS is easier
Name: AzamSharp
Date: 2/11/2008 8:03:28 AM
Comment: Hi Stevishere,
I think it is just a matter of preference! I like to use objects and domain layer to express my intension. You are right it would be much less code if you use ObjectDataSource or SQLDataSource. |
|
|
|
|
|
Subject: hi
Name: jagath
Date: 2/27/2008 3:21:41 AM
Comment: thanks for giving the information. |
|
|
|
|
|
Subject: Very useful for grid view
Name: Aayush
Date: 2/29/2008 10:42:24 PM
Comment: Thanks. Very useful for us. |
|
|
|
|
|
Subject: Sorting & DDL
Name: Rusty
Date: 3/5/2008 1:39:01 PM
Comment: Thanks for the example. It came in handy on one of my recent projects. Do you have any examples of how to sort a column with drop down menus similar to this example? Say for instance Chai in the example you provided appeared the product selected for more than one row. Any way to sort a column based off the selected value of the ddl?
Thanks a lot!! |
|
|
|
|
|
Subject: drop down list doesn't exist?
Name: Andi
Date: 3/8/2008 7:01:24 PM
Comment: I've copied all the code out almost as you have written down. But in visual studios it says that drop down list does not exist in the current document. Any suggestions would be helpful. |
|
|
|
|
|
Subject: all gridviewguys
Name: prawin
Date: 3/11/2008 9:46:42 PM
Comment: this article very nice |
|
|
|
|
|
Subject: GridViewGuys ROCK
Name: kathych644
Date: 3/18/2008 1:40:04 PM
Comment: AWESOME! Just a little change here, a little change there, and BAM! :) |
|
|
|
|
|
Subject: Compilation Error while using the query
Name: agnes
Date: 3/24/2008 7:03:48 AM
Comment: When i used the codings given here ,i got compilation error at the statement string query = @"SELECT p.CategoryID,p.ProductID, p.ProductName FROM Products p
SELECT c.CategoryID,c.CategoryName FROM Categories c";
|
|
|
|
|
|
Subject: RE: Compilation Error While using the query
Name: AzamSharp
Date: 3/25/2008 12:26:09 PM
Comment: Hi Agnes,
What is the exact error that you are facing? |
|
|
|
|
|
Subject: Dropinside Gridview
Name: Imran
Date: 3/25/2008 11:42:20 PM
Comment: Excellent..! |
|
|
|
|
|
Subject: Compilation Error While using the query
Name: Agnes
Date: 3/26/2008 5:56:01 AM
Comment: i did a mistake so only i got the error.Now i cleared it.
Any way thanks for ur help |
|
|
|
|
|
Subject: hi to all gridviewguys and thanks for providing us such valuable code
Name: Dhiraj
Date: 4/6/2008 9:39:36 PM
Comment: This article is very nice, but i want insert the check box at heaer of the grid view table when i select that check box all the reamning check boxes in that check box column will be selected.
This is my criteria please forword the links appropriate this one
Thank u. |
|
|
|
|
|
Subject: datagrid
Name: babu
Date: 4/8/2008 5:41:45 AM
Comment: when i am running this code i am getting no of rows.whatever list of items inside the dropdown that much rows are displaying.it is not displaying as like ur screenshot. |
|
|
|
|
|
Subject: gridview
Name: babu
Date: 4/8/2008 11:56:40 PM
Comment: when i'm running this code i'm getting no of rows.whatever list of items inside the dropdown that much rows are displaying.it is not displaying as like ur screenshot.please help me out how to solve |
|
|
|
|
|
Subject: gridview
Name: sandhya
Date: 4/9/2008 5:35:22 AM
Comment: we tried the above given code but the result we are getting not as u specified. the problem is the categoryName is repeatedly displaying as many items are there in dropdown respectively. please check and send us the solution i will waiting for the reply. |
|
|
|
|
|
Subject: RE: GridView
Name: AzamSharp
Date: 4/9/2008 8:25:34 PM
Comment: Hi Sandhya,
Please check your code again and make sure you are using all the hints that I have provided in the article. |
|
|
|
|
|
Subject: insert
Name: babu
Date: 4/10/2008 6:47:53 AM
Comment: the above result as specified in the screen shot we are getting but we want solution to insert data into database from dropdown dynamically. |
|
|
|
|
|
Subject: update every rows of gridview
Name: sandhya
Date: 4/18/2008 5:45:37 AM
Comment: how to update into database the selected item of dropdownlist in the gridview. as we selecting items dynamically from the all the dropdownlists it has to insert in to database having different columns related to corresponding dropdownlist. |
|
|
|
|
|
Subject: datagrid and combox
Name: ethanH03
Date: 4/23/2008 8:10:16 PM
Comment: kindly help me on creating a code in C# on how to populate data from the datagrid to 3 textboxes when I click the data on the datagrid. And also help me on how to create code in C# on how to add the data from the combox to the datagrid. The data from the combox will be added or populate in the datagrid. Thanks in advance |
|
|
|
|
|
Subject: Gridview Template columns
Name: Emy
Date: 5/9/2008 2:53:27 AM
Comment: Hello!
Thanks for the article. But what i would like to know is how i can get the row index when a dropdownlist performs a postback action within a row of the gridview.
Thanks!
|
|
|
|
|
|
Subject: RE: GridView Template Columns
Name: AzamSharp
Date: 5/9/2008 8:39:35 PM
Comment: Hi Emy,
Check out the following post:
http://aspadvice.com/blogs/azamsharp/archive/2006/12/08/Getting-Column-Value-Using-CheckBox-in-GridView-Autopostback-_3D00_-true.aspx
|
|
|
|
|
|
Subject: Very good t understand
Name: chithuraj
Date: 5/16/2008 1:34:14 AM
Comment: Ver good code. easy to analyse..Thanks a lot |
|
|
|
|
|
Subject: i want to code
Name: namasivayam
Date: 5/23/2008 7:14:05 AM
Comment: i want to code using gridview control same thing i use checkbox i select checkbox item move to another table |
|
|
|
|
|
Subject: RE: I want to code
Name: AzamSharp
Date: 5/27/2008 2:46:22 PM
Comment: Hi namasivayam,
Check out my GridView related articles. I have covered this topic several times.
|
|
|
|
|
|
Subject: Thanx
Name: Aniya Saxena
Date: 8/19/2008 8:29:06 AM
Comment: This eg. is very helpful to use adropdownlist in gridview but i also wants to know that how we can handle radio buttons in gridview and how we can group radio buttons in this... |
|
|
|
|
|
Subject: RE: Radio buttons inside GridView
Name: AzamSharp
Date: 8/20/2008 1:04:53 PM
Comment: Hi Aniya,
Check out this article:
http://gridviewguy.com/Articles/149_RadioButtons_inside_the_GridView_control.aspx
|
|
|
|
|
|
Subject: code
Name: asutosh
Date: 11/19/2008 10:22:24 PM
Comment: thank you |
|
|
|
|
|
Subject: binding multiple ddl to 1 column
Name: femi
Date: 12/11/2008 1:08:06 AM
Comment: pls am trying to bind values of 3 DDl ("Day","Month","Year")
into 1 column on my table "date" pls i need help quickly. |
|
|
|
|
|
Subject: problem with load and big ammount of data
Name: nelson
Date: 1/31/2009 8:12:06 PM
Comment: I have done the same and I have a problem. A gridview with 100 rows and the dropdown list with 100 records slows down the load of the page. Do you have an idea of how to fix it? |
|
|
|
|
|
Subject: re: problem loading too much data
Name: Mohammad Azam
Date: 2/3/2009 2:41:34 PM
Comment: Hi Nelson,
My suggestion would be to activate paging for the GridView control. Also, for fetching the 100 items for the DropDownList make sure you cache the items so you don't have to visit database again and again. Displaying 100+ rows in GridView at once will not serve a good purpose. Allow GridView to be paged. |
|
|
|
|
|
Subject: Is really good
Name: Neenu
Date: 4/30/2009 11:00:53 PM
Comment: Thanks a lot |
|
|
|
|
|
Subject: Excellent article!!
Name: Walter Unterberger
Date: 5/27/2009 12:04:42 AM
Comment: Excellent article!! Thanks for your explanation |
|
|
|
|
|
Subject: binding dropdownlist to gridview
Name: david padi
Date: 12/8/2009 1:13:27 AM
Comment: Hi
I actual have a problem. I am using ASP.NET VB, and I am trying to bind a dropdownlist and a textbox to a gridview using a button. Now, the dropdownlist, textbox and the button are in one page whilst the gridview is in another page.
The result in gridview should show only one row. I have been spending sleepless nights o this project, or maybe im just trying sumthing that is impossible.
i need both the coding and the whole procedure on how it's done. The coding should be in VB.NET, not C#
any help please. |
|
|
|
|
|
Subject: good
Name: salai
Date: 2/8/2010 10:26:37 AM
Comment: vow!!!! super.. thank your so much.. |
|
|
|
|
|
Subject: Getting selected item index change
Name: Abhilash
Date: 3/8/2010 11:08:51 PM
Comment: Hello,
Based on your code, I have a drop down list embedded inside a grid view. Now I cannot get the selectedindexchange of this drop down. Is there anyway I can get this. Please let me know what I have to do towards this
Thanks
Abhilash |
|
|
|
|
|
Subject: grid view
Name: prajakta
Date: 3/9/2010 11:21:40 PM
Comment: yes this is very good code but i have some different solution about my drop down list box is outside the gridview & i wish to display the selected drop down lists items corresponding data in gridview plz help me |
|
|
|
|
|
Subject: Grid View in Asp.net 2.0
Name: Vasu
Date: 4/2/2010 11:58:00 PM
Comment: Hi 2 all..,i hav sme problem abt binding data into the dropdownlist dynamically 4m database in asp.net.i hav a grid view ctrl in that first column placed empid,2nd as empname,and third as subjects.in the subjects columns i placed the dropdownlist.i created 2 tables one z regarding empdetails etc.. and the other is for Intersted subjects..
i want 2 display the corresponding subjects basing on the Empid in the Dropdownlist Dynamically...
This z my criteria plz anyone guid me Thank u all |
|
|
|
|
|
Subject: Grid View in Asp.net 2.0
Name: Vasu
Date: 4/3/2010 12:00:34 AM
Comment: Hi 2 all..,i hav sme problem abt binding data into the dropdownlist dynamically 4m database in asp.net.i hav a grid view ctrl in that first column placed empid,2nd as empname,and third as subjects.in the subjects columns i placed the dropdownlist.i created 2 tables one z regarding empdetails etc.. and the other is for Intersted subjects..
i want 2 display the corresponding subjects basing on the Empid in the Dropdownlist Dynamically...using C#.Net code.
This z my criteria plz anyone guid me Thank u all |
|
|
|
|
|
Subject: SelectedIndexChange for DropDownList - how?
Name: truthseeker
Date: 5/9/2010 3:11:44 AM
Comment: Do you know how can I add SelectedIndexChanged Event to dropdownlist? I've read about event bubbling but something dosen't work. :( Please help! |
|
|
|
|
|
Subject: This article
Name: Vijay
Date: 5/24/2010 12:34:54 PM
Comment: Very good article .
This is exactly what I was looking for! |
|
|
|
|
|
Subject: RE:
Name: asha
Date: 5/25/2010 4:35:49 AM
Comment: Very very nice article. I had very clear understanding of the topic |
|
|
|