|
|
|
hi all ,
i am mess with the one situation.
i am using asp.net2.0 ,C# and sql server 2005.
i have checkboxlist and based on user selection i creates dynamic controls(which code is in filterbutton_Click event and i call createcontrols function(public) in that ). but when i select value of that control(dynamic created) in another button click event(searchbutton) first it create fuction does not create dynamic control second as a result i do not get value of the control i call create function in filterbutton click and oninit()
please help
my create function is
private void createcontrols()
{
i = 1;
//if (CheckBoxListmst.SelectedIndex > -1)
//{
foreach (ListItem li in CheckBoxListmst.Items)
{
if (li.Selected == true)
{
Label label = new Label();
DropDownList dropdownlist = new DropDownList();
label.ID = "label" + i.ToString();
label.EnableViewState = true;
dropdownlist.ID = "dropdownlist" + i.ToString();
dropdownlist.EnableViewState = true ;
label.Text = li.Text;
//Label1.Text += dropdownlist.ID ;
i++;
//rdr = cmd.ExecuteReader();
for (int j = 0; j < 5; j++ )
{
ListItem ld = new ListItem();
ld.Text = j.ToString() ;
ld.Value = j.ToString();
dropdownlist.Items.Add(ld);
}
PlaceHolder1.Controls.Add(label);
PlaceHolder1.Controls.Add(dropdownlist);
Response.Write(" ");
}
}
}
// }
}
and i access it with the code as
Label objlbl;
DropDownList objdrop;
objlbl = this.PlaceHolder1.FindControl("label1") as Label;
objdrop = this.PlaceHolder1.FindControl("dropdownlist1") as DropDownList;
if ((objlbl != null) && (objdrop.SelectedIndex > -1 ))
{
Label1.Text = objlbl.Text; //Page.FindControl("label1").ToString() ;
Label2.Text = objdrop.SelectedValue;
}
i call createcontrol funtion in filterbutton_click and override oninit()
imaran khan
|
|
|
|
|
A couple of us asked you to use the debugger to see what controls are in your Placeholder1.Controls before these two lines:
objlbl = this.PlaceHolder1.FindControl("label1") as Label;
objdrop = this.PlaceHolder1.FindControl("dropdownlist1") as DropDownList;
Did you do that? What happened? I suspect a mismatch somehow between:
label.ID = "label" + i.ToString();
and
objlbl = this.PlaceHolder1.FindControl("label1") as Label;
You have to find out if a) your dynamic controls are (still) in Placeholder1, and what the IDs are that are stored.
|
|
|
|
|
i already checked id of both in both cases its generates same id
anyway thanks
imaran khan
|
|
|
|
|
That's not what we asked, but you're welcome anyways.
|
|
|
|
|
Hi all..
I have a timer in my aspx page which runs in a decreasing manner..i.e the timer starts at 5.0 min and ends by 0.0.. and i display it in my aspx page..
When i press the back button of my aspx page,the timer stops which results in the deviation of time...How to avoid this..? Someone help in this regard as early as possible...
Thanks & Regards,
Balaguru
|
|
|
|
|
What do you mean when you say "deviation of time"? It sounds rather intriguing.
|
|
|
|
|
I get the server time and diplay it in the Timer...When the timer stops due to click of the scroll button of the mouse..the timer starts ticking from where it left..this results in difference in time lapse
Regards,
Balaguru
|
|
|
|
|
Why did you start another thead? You already have a recent thread about time deviation in a timer on an aspx page.
Of course the timer stops when you navigate to a different page. If you want the timer functionality to continue, you have to start a new timer on that page that continues where the previous timer was stopped.
---
single minded; short sighted; long gone;
|
|
|
|
|
I am not starting another thread,rather when my testing team test my application ,this problem occurs..How to solve it..?
Regards,
Balaguru
|
|
|
|
|
Balagurunathan S wrote: I am not starting another thread
You started a new thread in the forum, for no apparent reason.
Balagurunathan S wrote: when my testing team test my application ,this problem occurs..How to solve it..?
I offered a solution in my previous post.
---
single minded; short sighted; long gone;
|
|
|
|
|
what things i can change IN THE GLOBAL ASSEMBY CACHE.I KNOW IT MAKES CHANGES FOR ALL APPLICATION.I WANTED TO SEE THE CHANGE , BY MODIFYING THE GLOBAL ASSEMBLY CACHE (MACHINE.CONFIG).
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
u add the database connection string in machine con fig then see what happen and other example is:- u delete all the compiler then see what happen
please do it i am wating
Piyush Vardhan Singh
Programmer
TAS NewDelhi
India
|
|
|
|
|
my dear GLOBAL ASSEMBLY CACHE and MACHINE.CONFIG both are different thing ok
Piyush Vardhan Singh
Programmer
TAS NewDelhi
India
|
|
|
|
|
Hi all..
I have a timer in my aspx page which runs in a decreasing manner..i.e the timer starts at 5.0 min and ends by 0.0.. and i display it in my aspx page..
when i click the scroll button of my mouse the timers stops and when i release it the timer starts working having the value with which it ended during my click..Time deviation occurs as result of this...
Somone kindly help in this regard...
Thanks & Regards,
Balaguru
|
|
|
|
|
A code snippet could help people answer your question here.
|
|
|
|
|
Hi all.
I need javascript code to avoid copy paste option in text boxes..some one help me as early as possible..
Thanks & Regards,
Balaguru
|
|
|
|
|
|
i m editing records through datagrid..behind my update button i've written following code..
String str = " ";
for (int i = 0; i == editgrid.RowCount - 1; i++)
{
str = "UPDATE criminal SET cr_id = " + editgrid.Rows[i].Cells[1].Value + ", cr_name= '" + editgrid.Rows[i].Cells[2].Value + "', cr_desc='" + editgrid.Rows[i].Cells[3].Value + "' ,cr_pic= '" + editgrid.Rows[i].Cells[4].Value + "', no_times ='" + editgrid.Rows[i].Cells[5].Value + "' WHERE cr_id = " + editgrid.Rows[i].Cells[1].Value;
SqlCommand com = new SqlCommand(str, conn);
com.ExecuteNonQuery();
label2.Visible = true;
}
it is not giving any errors but records are not updated,yet
can anybody help me??
software student
|
|
|
|
|
Print your query somewhere and execute it directly in query analyzer. You can find out what is wrong with query.
|
|
|
|
|
Ok, first you are looping through the entire grid and updating every row even if it was not updated. Normally with a datagrid, you have an edit button which puts the row into edit mode. When the row is in edit mode you have a save and cancel button. Then with your save button you run the update for that single row.
Now several post will probably follow talking about sql injection attacts. You should use a parameterize query or a stored procedure to do this update.
Finally, my best guess to what your update problem is:
I would guess this isn't the crid you think it is:
editgrid.Rows[i].Cells[1].Value
Hope that helps.
Ben
|
|
|
|
|
why you have put double 'equal to' simbol in FOR loop?
|
|
|
|
|
Asalam-O-Alikum
plz any one tell me how to retriev multiple datakey values fom grid
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
I usually create template columns which have a label in them which is the key and then I mark the label as visible = false.
Hope that helps.
Ben
|
|
|
|