.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

implement Drop Down list item in Gridview

Posted By: Nachi     Posted Date: March 17, 2012    Points:5   Category :ASP.Net

implement Drop Down list item in Gridview


Hi All,

I have a big clarification in grid view, this question something interesting and also little duff.

I have table of three field namely id, name and destination

I know already how to add and display this three columns in grid view including check box & button for each row generated and fetching third column in drop down list.

I need to know when i checked the check box of particular column,then the drop down list item is selected and last finally the button is click, the output needed is another grid view (nested grid view)displaying the select row information.

I know its very interesting and simple for experts? I have attached the file for your reference.

4shared[dot]com[slash]file[slash]7LCSw_4I[slash]ltest[dot]html

Please change the dot and slash to keyboard character and download it....


Responses
Author: Pawan Awasthi             
Posted Date: March 24, 2012     Points: 20   

http://www.dotnetspark.com/Forum/3275-implement-drop-down-list-item-gridview.aspx

Hai Nachi,

The first thing, you need to do is that you need to fill the dropdon list while crating the row in OnRowCreadtedEvent. So in the gridView OnRowCreated event, find the GridView using the FindControl method and then you can add the items.
After getting, in the on row databound event, you need to make the item as the selected item.
see below onRowCreated event as:

protected void gvPoolStatus_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlDesig = (DropDownList)e.Row.Cells[3].FindControl("dd_designation");
if (ddlDesig != null)
{
ddlDesig.Items.Add("items");//add the items from the list or dataset
}
}
}

see below for the onRowDataBound event as :
        
protected void gvPoolStatus_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlDesig = (DropDownList)e.Row.Cells[3].FindControl("dd_designation");
if(ddlDesig != null)
ddlDesig.SelectedItem.Text= e.Row.Cells[3].Text;
}
}
Hope it will help you.

Regards,
Pawan Awasthi
Pawansoftit@gmail.com
(Whats App)+91 8123489140
(cell No.) +60 143651476
Author: chikkanti             
Posted Date: June 06, 2012     Points: 20   


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend