Click here to Skip to main content
15,888,263 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: ASP Pages are not running in .net 1.1Application Pin
anilpal25-Mar-09 21:33
anilpal25-Mar-09 21:33 
GeneralRe: ASP Pages are not running in .net 1.1Application Pin
yadlaprasad25-Mar-09 21:47
yadlaprasad25-Mar-09 21:47 
GeneralRe: ASP Pages are not running in .net 1.1Application Pin
anilpal25-Mar-09 22:37
anilpal25-Mar-09 22:37 
QuestionDrop Down Lists Pin
scar_face25-Mar-09 20:47
scar_face25-Mar-09 20:47 
AnswerRe: Drop Down Lists Pin
anilpal25-Mar-09 22:45
anilpal25-Mar-09 22:45 
GeneralRe: Drop Down Lists Pin
scar_face25-Mar-09 23:01
scar_face25-Mar-09 23:01 
GeneralRe: Drop Down Lists Pin
anilpal25-Mar-09 23:15
anilpal25-Mar-09 23:15 
GeneralRe: Drop Down Lists Pin
scar_face25-Mar-09 23:29
scar_face25-Mar-09 23:29 
Please have a look at my code:

<asp:GridView ID="grd" runat="server" OnRowDataBound="grd_RowDataBound">   
    
  
<Columns>    
  
  
<asp:TemplateField HeaderText="names">   
  
    
  
  
<ItemTemplate>  
  
    
  
  
<asp:DropDownList ID="name" runat="server" OnSelectedIndexChanged="onSelectChangeddl"></asp:DropDownList>  
  
    
  
</ItemTemplate>  
  
    
  
</asp:TemplateField>  
  
    
  
<asp:TemplateField HeaderText="age">   
  
    
  
<ItemTemplate>  
  
    
  
<asp:DropDownList ID="age" runat="server" AutoPostBack="true">   
  
    
  
</asp:DropDownList>  
  
    
  
  
</ItemTemplate>  
  
    
  
</asp:TemplateField>  
  
</Columns>  
  
    
  
</asp:GridView>  



In c# code, i am trying to change the values of the second drop down list based on the value selected in the first. I am doing this as below:


foreach (GridViewRow row in grd.Rows)   
{   
DropDownList ddl1 = (DropDownList)row.FindControl("name");   
DropDownList ddl = (DropDownList)row.FindControl("age");   
  
  
if (ddl.SelectedValue.ToString() != "---Select---")   
  
{   
  
}   
  
else   
    
  
{   
  
ddl.Items.Clear();   
  
}   
  
    
  
SqlCommand SPComm = new SqlCommand("someStoredProcedure", myConn);   
  
SPComm.CommandType = CommandType.StoredProcedure;   
  
SqlParameter param = SPComm.Parameters.Add("@something", SqlDbType.NVarChar, 50);   
  
param.Value = something;   
  
dr = SPComm.ExecuteReader();  //dr is sqlDataReader   
  
int i = 0;   
  
while (dr.Read())   
  
{   
  
ddl.Items.Insert(i, dr.GetString(0));   
  
}   
  
dr.Close();   
  
ddl.Items.Insert(0, "---Select---");   
  
}  



In the above code, all the values in the second drop down list are getting duplicated based on the selected index changed event handler of the first drop down list.

scarface

GeneralRe: Drop Down Lists Pin
anilpal26-Mar-09 2:54
anilpal26-Mar-09 2:54 
QuestionRewrite Url on page post Back Pin
amit sahu2025-Mar-09 20:34
amit sahu2025-Mar-09 20:34 
AnswerRe: Rewrite Url on page post Back Pin
anilpal25-Mar-09 22:49
anilpal25-Mar-09 22:49 
GeneralRe: Rewrite Url on page post Back Pin
amit sahu2025-Mar-09 22:56
amit sahu2025-Mar-09 22:56 
GeneralDAL & BLL Pin
Ramkumar_S25-Mar-09 20:03
Ramkumar_S25-Mar-09 20:03 
GeneralRe: DAL & BLL Pin
N a v a n e e t h25-Mar-09 20:24
N a v a n e e t h25-Mar-09 20:24 
GeneralRe: DAL & BLL Pin
Abhijit Jana25-Mar-09 20:48
professionalAbhijit Jana25-Mar-09 20:48 
GeneralRe: DAL & BLL Pin
Vimalsoft(Pty) Ltd25-Mar-09 21:56
professionalVimalsoft(Pty) Ltd25-Mar-09 21:56 
QuestionFile viewing from another directory Pin
CrazyCoder2625-Mar-09 18:56
CrazyCoder2625-Mar-09 18:56 
AnswerRe: File viewing from another directory Pin
tech60325-Mar-09 19:04
tech60325-Mar-09 19:04 
GeneralRe: File viewing from another directory Pin
CrazyCoder2625-Mar-09 19:14
CrazyCoder2625-Mar-09 19:14 
GeneralRe: File viewing from another directory Pin
N a v a n e e t h25-Mar-09 20:38
N a v a n e e t h25-Mar-09 20:38 
GeneralRe: File viewing from another directory Pin
CrazyCoder2626-Mar-09 22:00
CrazyCoder2626-Mar-09 22:00 
AnswerRe: File viewing from another directory Pin
Ravindra Bisen25-Mar-09 22:50
Ravindra Bisen25-Mar-09 22:50 
QuestionProblem in modal pop in asp.net 2008 ajax Pin
hozsam25-Mar-09 18:43
hozsam25-Mar-09 18:43 
Questionhow to redirect to main page when session expired Pin
prasadbuddhika25-Mar-09 18:14
prasadbuddhika25-Mar-09 18:14 
AnswerRe: how to redirect to main page when session expired Pin
tech60325-Mar-09 19:09
tech60325-Mar-09 19:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.