|
How to write code for Dynamic Radio buttons events in asp.net .
Here I'm geting data from database .
My project Flow is:
Step1:Select Location In DropDownlist box
Step2:Display The various cuisines in RadioButton.
Step3:When ever I select Radiobutton it's not perform event.
Please Give Me solution as early as possible..
i'm using ASp.NET/C#
Thank you..
Kantharao
modified on Tuesday, June 23, 2009 9:02 AM
|
|
|
|
|
Your dynamic controls will only fire events if they are created before page load, otherwise, viewstate is not restored for them.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
kantharao wrote: How to write code for Dynamic Radio buttons events in asp.net .
Here is the code:
protected void Page_Load(object sender, EventArgs e)
{
RadioButton rbt = new RadioButton();
rbt.CheckedChanged += new EventHandler(rbt_checked);
rbt.AutoPostBack = true;
//create a panel in design.
Panel1.Controls.Add(rbt);
}
protected void rbt_checked(object sender, EventArgs e)
{
Response.Write("hi");
}
|
|
|
|
|
I have a webpart and dropdown property and user can select value1 or value2 .If user select value1 ,webpart1 will be added else webpart2 will be added with their properties(configable).How do I resolve this problem?
|
|
|
|
|
magicFire wrote: I have a webpart and dropdown property and user can select value1 or value2 .If user select value1 ,webpart1 will be added else webpart2 will be added with their properties(configable).
You mean you want to add web parts based on User selection from Drop down ?
|
|
|
|
|
Yes I want dropdown property allow user select which web part is loaded?
|
|
|
|
|
Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim chkTest As CheckBox = DirectCast(sender, CheckBox)
Dim grdRow As GridViewRow = DirectCast(chkTest.NamingContainer, GridViewRow)
Dim txtname As TextBox = DirectCast(grdRow.FindControl("txtName"), TextBox)
If chkTest.Checked Then
txtname.ReadOnly = False
txtname.ForeColor = System.Drawing.Color.Black
Else
txtname.ReadOnly = True
txtname.ForeColor = System.Drawing.Color.Blue
End If
End Sub
|
|
|
|
|
KhandelwalA wrote: Dim txtname As TextBox = DirectCast(grdRow.FindControl("txtName"), TextBox)
Did you check textbox object here?
Did you searched google for it? This is the one of the common error message.
|
|
|
|
|
you have to find the row in which the textbox is present. I am not familiar with VB so i written the code in C#
for(int i=0;i < GVLeads.Rows.Count;i++)
{
TextBox txt = (TextBox)GVLeads.Rows[i].FindControl("TextBox2");
txt.ReadOnly = true;
}
//convert it to VB it iwll work fine
modified on Tuesday, June 23, 2009 6:42 AM
|
|
|
|
|
thanks for ur reply..........but i want to know what is basic reason behind this kind of error.......it comes many times...........can u explain me plzzz??
|
|
|
|
|
|
yes, the object reference error comes as per your coding is you have multiple rows in the grid, But you have not mentioned in which row the textbox is presented. YOu can just see in your code itself.
//instead of this:
Dim txtname As TextBox = DirectCast(grdRow.FindControl("txtName"), TextBox)
//use this
Dim txtname As TextBox = DirectCast(grdRow.Rows[0].FindControl("txtName"), TextBox)
txtname.ReadOnly = False
//for this only the first row of the grid textbox will be readonly = false.
//if you want for all the rows then put for loop
for(i=0;i < grdRow.Rows.count;i++)
{
Dim txtname As TextBox = DirectCast(grdRow.Rows[i].FindControl("txtName"), TextBox)
txtname.ReadOnly = False
}
//I hope you understood now
|
|
|
|
|
|
its still giving me the same error..... .....plz help me
|
|
|
|
|
send me the code wat you are using now
|
|
|
|
|
Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim chkTest As CheckBox = DirectCast(sender, CheckBox)
Dim grdRow As GridViewRow = DirectCast(chkTest.NamingContainer, GridViewRow)
Dim txtname As TextBox = DirectCast(grdRow.FindControl("txtName"), TextBox)
If chkTest.Checked Then
txtname.ReadOnly = False
txtname.ForeColor = System.Drawing.Color.Black
Else
txtname.ReadOnly = True
txtname.ForeColor = System.Drawing.Color.Blue
End If
End Sub
|
|
|
|
|
KhandelwalA wrote: Dim txtname As TextBox = DirectCast(grdRow.FindControl("txtName"), TextBox)
after clearly explaining, you havn't changed anything. You have to include for loop and include rows in the find control.
|
|
|
|
|
that i did..........but still giving error man........look at this
Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim chkTest As CheckBox = DirectCast(sender, CheckBox)
Dim grdRow As GridViewRow = DirectCast(chkTest.NamingContainer, GridViewRow)
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim txtname As TextBox = DirectCast(GridView1.Rows(i).FindControl("txtName"), TextBox)
txtname = Nothing
If chkTest.Checked Then
txtname.ReadOnly = False
txtname.ForeColor = System.Drawing.Color.Black
Else
txtname.ReadOnly = True
txtname.ForeColor = System.Drawing.Color.Blue
End If
Next
End Sub
|
|
|
|
|
KhandelwalA wrote: txtname = Nothing
remove this.
|
|
|
|
|
that i did............but still giving error
|
|
|
|
|
I have changed your code a bit.Try using it....N.B : have you checked the textbox name is txtName?It's case sensitive..check it.
Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim chkTest As CheckBox = DirectCast(sender, CheckBox)
Dim fc As DataControlFieldCell=DorectCast(chkTest.Parent,DataControlFieldCell)
Dim grdRow As GridViewRow=DirectCast(fc.Parent,GridViewRow)
Dim txtname As TextBox = DirectCast(grdRow.FindControl("txtName"), TextBox)
If chkTest.Checked Then
txtname.ReadOnly = False
txtname.ForeColor = System.Drawing.Color.Black
Else
txtname.ReadOnly = True
txtname.ForeColor = System.Drawing.Color.Blue
End If
End Sub
CC26
|
|
|
|
|
CrazyCoder26 wrote: I have changed your code a bit.Try using it....N.B : have you checked the textbox name is txtName?It's case sensitive..check it.
i dont think changing name will make any difference.
|
|
|
|
|
Most probably you didn't see my code properly...I didn't ask to change name.I told to check whether the textbox name is correct.
For example....if the textbox name is txtName, then txtname won't work
CC26
|
|
|
|
|
Dear All,
Our requirement is a cab has assigned to Pick and Drop the employee for each and every shifts for the selective date. So, we need to show how much distance a cab has travelled, then we need to show that cab has been assigned for Pick/Drop for all the selective date.
As per my Procedure we can get the "Shift Date Time", "Cab No", "Pick/Drop" value, etc....
In Range chart I need to show the "Shift Time" in "X Axis" like "9 AM", "10 AM", "11 AM".....upto Next day "8 AM".
then In "Y Axis" I need to show "Shift Date Time" & "Cab No." which come from table.
In "Y Axis" i can not show the "Shift Date Time", So, I tried to show in "X Axis", but I can show only shift Date not time.
Actually I need to show the shift date in "Y Axis" only.
If any one have the solution, Please reply me.
Thanks in Advance.
Regards,
Jegan.K
9994388922
Jegan
|
|
|
|
|
I encountered this error in the web .config please help me out.
Could not load file or assembly 'Microsoft.Data.SqlXml, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
Am encountering this problem in the web .config
thanks in anticipation.
|
|
|
|