Click here to Skip to main content
15,920,508 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Any one know about session? Pin
wk63327-Jul-07 5:30
wk63327-Jul-07 5:30 
GeneralRe: Any one know about session? Pin
vurugonda27-Jul-07 5:50
vurugonda27-Jul-07 5:50 
GeneralRe: Any one know about session? Pin
wk63327-Jul-07 6:12
wk63327-Jul-07 6:12 
GeneralHow to combine two applications in one application Pin
vurugonda9-Aug-07 17:47
vurugonda9-Aug-07 17:47 
GeneralRe: How to combine two applications in one application Pin
wk63310-Aug-07 6:15
wk63310-Aug-07 6:15 
QuestionTotal string length Pin
VK-Cadec26-Jul-07 5:06
VK-Cadec26-Jul-07 5:06 
AnswerRe: Total string length Pin
kubben26-Jul-07 5:37
kubben26-Jul-07 5:37 
Questiongetting dynamically created control's value as null Pin
imranafsari26-Jul-07 5:05
imranafsari26-Jul-07 5:05 
Dear All,
I am mess with one situation let me explain the scenario.
I am making search form where I display 15 field in checkboxlist and user select one or two or three or any no to all field. Depending on his selection (he tick the field and click filter button ) Now in filter button click I create label and dropdownlist control(populated from database) and add it to placeholder control. Now I select value and click the search button. Now in search button I need to access those control and its selected value(ie label and droplistbox ).
I have made function to create label and dropdownlistbox which is

private void createcontrols()
{
foreach (ListItem li in CheckBoxListmst.Items)
{
if (li.Selected == true)
{

//code added to fetch dropdownlist
setting = ConfigurationManager.ConnectionStrings["StyleSearchConnectionString"];
if (setting != null)
{
Code to access data for populating dropdownlistbox
try
{
// added controls
Label label = new Label();
DropDownList dropdownlist = new DropDownList();
label.ID = "label" + i.ToString();
dropdownlist.ID = "dropdownlist" + .ToString();


i++;
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Items for dropdownlist


}
PlaceHolder1.Controls.Add(label);
PlaceHolder1.Controls.Add(dropdownlist);



}

catch (SqlException ex)
{

}

Now this create function I call in one in filter button click event and second as

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
createcontrols();
}

Now in seach button click event when I am trying to access
Code is

Label objlbl;
DropDownList objdrop;
objlbl = this.Page.FindControl("label1") as Label;
objdrop = this.Page.FindControl("dropdownlist1") as DropDownList;if ((objlbl != null) && (objdrop != null))
{
cmd.Parameters.Add("@para1", SqlDbType.VarChar).Value = objlbl.Text; //Page.FindControl("label1").ToString() ;
cmd.Parameters.Add("@value1", SqlDbType.VarChar).Value = objdrop.SelectedValue;
}
I am getting objlbl and objdrop as null.


Please help


thanks




imaran khan

AnswerRe: getting dynamically created control's value as null Pin
Tarakeshwar Reddy26-Jul-07 5:15
professionalTarakeshwar Reddy26-Jul-07 5:15 
GeneralRe: getting dynamically created control's value as null Pin
imranafsari26-Jul-07 5:35
imranafsari26-Jul-07 5:35 
GeneralRe: getting dynamically created control's value as null Pin
Tarakeshwar Reddy26-Jul-07 6:03
professionalTarakeshwar Reddy26-Jul-07 6:03 
AnswerRe: getting dynamically created control's value as null Pin
wk63326-Jul-07 5:34
wk63326-Jul-07 5:34 
GeneralRe: getting dynamically created control's value as null Pin
imranafsari26-Jul-07 5:42
imranafsari26-Jul-07 5:42 
GeneralRe: getting dynamically created control's value as null Pin
wk63326-Jul-07 5:56
wk63326-Jul-07 5:56 
QuestionResponse.Redirect Pin
Civic0626-Jul-07 4:33
Civic0626-Jul-07 4:33 
AnswerRe: Response.Redirect Pin
Blue_Boy26-Jul-07 4:42
Blue_Boy26-Jul-07 4:42 
QuestionProblem getting information from a database. [modified] Pin
Muntyness26-Jul-07 4:03
Muntyness26-Jul-07 4:03 
AnswerRe: Problem getting information from a database. Pin
Blue_Boy26-Jul-07 4:08
Blue_Boy26-Jul-07 4:08 
GeneralProblem fixed Pin
Muntyness26-Jul-07 4:20
Muntyness26-Jul-07 4:20 
AnswerRe: Problem getting information from a database. Pin
Paddy Boyd26-Jul-07 4:27
Paddy Boyd26-Jul-07 4:27 
QuestionForms Auth & SSO Pin
Ridge Howison26-Jul-07 3:52
Ridge Howison26-Jul-07 3:52 
QuestionCodes of paramaters of Crystal Report in C # ? Pin
Fabu197126-Jul-07 3:32
Fabu197126-Jul-07 3:32 
AnswerRe: Codes of paramaters of Crystal Report in C # ? Pin
Blue_Boy26-Jul-07 4:00
Blue_Boy26-Jul-07 4:00 
Questionproblems with office components Pin
johno196726-Jul-07 3:30
johno196726-Jul-07 3:30 
QuestionThird party authentication [modified] Pin
Abhishek Joshi26-Jul-07 3:29
Abhishek Joshi26-Jul-07 3:29 

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.