顯示具有 RadioButton 標籤的文章。 顯示所有文章
顯示具有 RadioButton 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] Online Examination system


I am working in a project on online examination systm in which  i have binded radiobuttons in formview and value in radiobuttons comes from  database where i have stored options for particular question...


Now i want to know how to save value of radiobutton option that was choosen by user and how to move on next question when user clicks on next button..



 Plz if anyone of you can help...



Hi,


To Save selected radio button option in database check this,


http://www.c-sharpcorner.com/blogs/8328/insert-radiobutton-values-into-database.aspx


I assume that your questions are coming from database, same kind of scenario is discussed here,


http://forums.asp.net/t/1918270.aspx/1?Display+Data+in+Textbox+Next+Previous+First+Last+form+database+in+asp+net+and+c+


You can use repeater control to show questions and options one at a time.


Hope this helps!



on button click event, u can read value from radiobuttonlist


string strSelectRadio = ((RadioButtonList) FormView1.FindControl("radio_buttonlist_id")).SelectedValue;


then, store value of strSelectedRadio in database and again fetch next question from database and rebind formview


hope this helps...


[RESOLVED] Online Examination system


I am working in a project on online examination systm in which  i have binded radiobuttons in formview and value in radiobuttons comes from  database where i have stored options for particular question...


Now i want to know how to save value of radiobutton option that was choosen by user and how to move on next question when user clicks on next button..



 Plz if anyone of you can help...



Hi,


To Save selected radio button option in database check this,


http://www.c-sharpcorner.com/blogs/8328/insert-radiobutton-values-into-database.aspx


I assume that your questions are coming from database, same kind of scenario is discussed here,


http://forums.asp.net/t/1918270.aspx/1?Display+Data+in+Textbox+Next+Previous+First+Last+form+database+in+asp+net+and+c+


You can use repeater control to show questions and options one at a time.


Hope this helps!



on button click event, u can read value from radiobuttonlist


string strSelectRadio = ((RadioButtonList) FormView1.FindControl("radio_buttonlist_id")).SelectedValue;


then, store value of strSelectedRadio in database and again fetch next question from database and rebind formview


hope this helps...


[RESOLVED] Checkbox


i,ve a repeater


then datalist


and then checkbox,textbox and redaio button



                    runat="server">




<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:
<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]





<%-- ID="chkItemOptionalModifiers" OnSelectedIndexChanged="chkItemOptionalModifiers_SelectedIndexChanged"
runat="server">
--%>














LH
Full
RH







how i can get the valuse of textbox,checkbox,hiddenfiels.... in jquery..





hi nafees,


as you have used css-classes for both check-box and text-box, so, you can use these with jQuery selectors, like this,


$(".chkList").each( function(){ //your code } );
$(".spinnnerOptional").each( function(){ //your code } );

thanks


[RESOLVED] Checkbox


i,ve a repeater


then datalist


and then checkbox,textbox and redaio button



                    runat="server">




<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:
<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]





<%-- ID="chkItemOptionalModifiers" OnSelectedIndexChanged="chkItemOptionalModifiers_SelectedIndexChanged"
runat="server">
--%>














LH
Full
RH







how i can get the valuse of textbox,checkbox,hiddenfiels.... in jquery..





hi nafees,


as you have used css-classes for both check-box and text-box, so, you can use these with jQuery selectors, like this,


$(".chkList").each( function(){ //your code } );
$(".spinnnerOptional").each( function(){ //your code } );

thanks


[RESOLVED] Checkbox


i,ve a repeater


then datalist


and then checkbox,textbox and redaio button



                    runat="server">




<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:
<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]





<%-- ID="chkItemOptionalModifiers" OnSelectedIndexChanged="chkItemOptionalModifiers_SelectedIndexChanged"
runat="server">
--%>














LH
Full
RH







how i can get the valuse of textbox,checkbox,hiddenfiels.... in jquery..





hi nafees,


as you have used css-classes for both check-box and text-box, so, you can use these with jQuery selectors, like this,


$(".chkList").each( function(){ //your code } );
$(".spinnnerOptional").each( function(){ //your code } );

thanks


[RESOLVED] Checkbox


i,ve a repeater


then datalist


and then checkbox,textbox and redaio button



                    runat="server">




<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:
<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]





<%-- ID="chkItemOptionalModifiers" OnSelectedIndexChanged="chkItemOptionalModifiers_SelectedIndexChanged"
runat="server">
--%>














LH
Full
RH







how i can get the valuse of textbox,checkbox,hiddenfiels.... in jquery..





hi nafees,


as you have used css-classes for both check-box and text-box, so, you can use these with jQuery selectors, like this,


$(".chkList").each( function(){ //your code } );
$(".spinnnerOptional").each( function(){ //your code } );

thanks


[RESOLVED] Checkbox


i,ve a repeater


then datalist


and then checkbox,textbox and redaio button



                    runat="server">




<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:
<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]





<%-- ID="chkItemOptionalModifiers" OnSelectedIndexChanged="chkItemOptionalModifiers_SelectedIndexChanged"
runat="server">
--%>














LH
Full
RH







how i can get the valuse of textbox,checkbox,hiddenfiels.... in jquery..





hi nafees,


as you have used css-classes for both check-box and text-box, so, you can use these with jQuery selectors, like this,


$(".chkList").each( function(){ //your code } );
$(".spinnnerOptional").each( function(){ //your code } );

thanks


[RESOLVED] Checkbox


i,ve a repeater


then datalist


and then checkbox,textbox and redaio button



                    runat="server">




<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:
<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]





<%-- ID="chkItemOptionalModifiers" OnSelectedIndexChanged="chkItemOptionalModifiers_SelectedIndexChanged"
runat="server">
--%>














LH
Full
RH







how i can get the valuse of textbox,checkbox,hiddenfiels.... in jquery..





hi nafees,


as you have used css-classes for both check-box and text-box, so, you can use these with jQuery selectors, like this,


$(".chkList").each( function(){ //your code } );
$(".spinnnerOptional").each( function(){ //your code } );

thanks


[RESOLVED] Javascript validation for radio buttons in repeater control


I have a repeater control for feedback




Code is

























FeedBack









Select an item













Now i need javascript validate so that user selects answer for all the questions.





Hi,


Please refer the thread which maybe helpful to you


http://forums.asp.net/t/1537904.aspx/1


http://www.encodedna.com/2013/02/aspdotnet.gridview-row-jquery.htm


Hope it can help you



Assume your repeater is wrapped into some div with id="surveyContainer" and every item template in repeater is wrapped in div with class="survey-question":


function isValid(){
var countQuestions = $(".survey-question").length;
var countChecked = $(":checked", $("#surveyContainer")).length;
return countQuestions == countChecked;
}

If you have checkboxes or select elements somewhere in a page - change the selector to be more strict


$("[type=radio]:checked")






[RESOLVED] RadiobuttonList




public partial class MasterPage : System.Web.UI.MasterPage

{

protected void Page_Load(object sender, EventArgs e)

{


}

protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)

{



}


protected void RadioButtonList1_CheckedChanged(object sender, EventArgs e)

{

if (RadioButtonList1.SelectedValue == "0")

{

Response.Redirect("generated.aspx");


}

else if (RadioButtonList1.SelectedValue == "1")

{

Response.Redirect("notgenerated.aspx");

}

}




RepeatDirection="Horizontal" style="margin-left: 346px"

onselectedindexchanged="RadioButtonList1_SelectedIndexChanged" OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true"


Width="579px">

Generated List

Not Generated List

New List






 When i click the radio button it does not redirect .....









Try this


You used OnCheckedChanged="RadioButton1_CheckedChanged"  event please change your code to inside of RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) and remove  the OnCheckedChanged="RadioButton1_CheckedChanged"  
in control and server side 


protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{

if (RadioButtonList1.SelectedValue == "0")
{
Response.Redirect("generated.aspx");

}
else if (RadioButtonList1.SelectedValue == "1")
{
Response.Redirect("notgenerated.aspx");
}

}






RepeatDirection="Horizontal" style="margin-left: 346px" 
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true"
Width="579px">
Generated List
Not Generated List
New List






Working !! THANX





akkibansal



This is not working as well






Your code working to me !! What's your exact problem ?



Your code in my Application 



Client side


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>









RepeatDirection="Horizontal" style="margin-left: 346px"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true"
Width="579px">
Generated List
Not Generated List
New List







Server side


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{

if (RadioButtonList1.SelectedValue == "0")
{
Response.Redirect("generated.aspx");

}
else if (RadioButtonList1.SelectedValue == "1")
{
Response.Redirect("notgenerated.aspx");
}

}
}








[RESOLVED] RadioButton in Gridview


Hi,


I have table whit field: "picid" , and a gridview whit radiobutton:








 




In gridview, i want only one radiobutton is checked,


and when click the other radiobutton, current record "picid" field is 1 and other records picid is 0, (table Update)


I want in blew code:


update pic set picid=1 where radiobutton selected and other records of gridviwe --> picid=0


If e.CommandName = "select" Then
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("picup", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@picid", e.CommandArgument.ToString()))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
End If

How i do?


Thank you for your attention...





anuj_koundal



Use groupname property to group them.

Refrence: http://www.codingfusion.com/Post/Write-a-program-to-list-your-favourate-colors-usin







This is not solve my problem,


i use only one radiobutton in gridview ... and  ...



you have to fire SelectCommand from your grid, to properly catch the grid-selection changed event. and you should use GroupName properly as well,




Please send me more code for this, if possible. 1. I want only 1 radiobutton checked in every time. 2. I want when radiobutton checked: picid field of current record set =1 and picid filed other records set=0

For your first requirement only one radio button is checked : 







groupname="abc" ID="RadioButton1" runat="server" Checked='<%# Eval("picid") %>' />
 




For your second requirement you have to write your own code in codebehind.If you can provide your storedprocedure may be I can help more.



To check one radio try this


    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}









oned_gk



To check one radio try this
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}







Thank you, this is work,


for update rows how i do? in gridview 



I want "picid" of selected row (radiobutton checked=true) = 1 and other row shown in gridview => picid=0,


please help me,



I want try this, but thi is not work:








 





and:


        If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
For Each row As GridView In GridView1.Rows
Dim constr As String = ConfigurationManager.ConnectionStrings("starfairConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("firpicup1", con)
cmd.CommandType = CommandType.StoredProcedure
Dim RowIndex As Integer = Convert.ToInt32(e.CommandArgument)
cmd.Parameters.Add(New SqlParameter("@picid", TextBox4.Text))
Dim rb As RadioButton = DirectCast(row.FindControl("RadioButton1"), RadioButton)
cmd.Parameters.Add(New SqlParameter("@main1", rb.Checked))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
Next







[RESOLVED] Radiobutton datakey in gridview


Hi,


I have a radiobutton in gridview:








 





but


   If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
end if

not work, but this code worked for :


 

but for radiobutton not work, please help me.









Add attribute of gridview onRowCommand="GridView1_RowCommand"



protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

{


         if(e.CommandName == "Select")


         {


               //Write your code here


         }


}





This code worked for linkbutton. For radiobutton this code not work.

I think require CommandArgument in radiobutton,


How to add this radiobutton?



Instead of firing rowommand event, use radioButton's selectedIndexChanged method where u can get selected value and  you can directly assign that value to textbox...


Just change your approach if possible...


[RESOLVED] RadioButton in Gridview


Hi,


I have table whit field: "picid" , and a gridview whit radiobutton:








 




In gridview, i want only one radiobutton is checked,


and when click the other radiobutton, current record "picid" field is 1 and other records picid is 0, (table Update)


I want in blew code:


update pic set picid=1 where radiobutton selected and other records of gridviwe --> picid=0


If e.CommandName = "select" Then
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("picup", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@picid", e.CommandArgument.ToString()))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
End If

How i do?


Thank you for your attention...





anuj_koundal



Use groupname property to group them.

Refrence: http://www.codingfusion.com/Post/Write-a-program-to-list-your-favourate-colors-usin







This is not solve my problem,


i use only one radiobutton in gridview ... and  ...



you have to fire SelectCommand from your grid, to properly catch the grid-selection changed event. and you should use GroupName properly as well,




Please send me more code for this, if possible. 1. I want only 1 radiobutton checked in every time. 2. I want when radiobutton checked: picid field of current record set =1 and picid filed other records set=0

For your first requirement only one radio button is checked : 







groupname="abc" ID="RadioButton1" runat="server" Checked='<%# Eval("picid") %>' />
 




For your second requirement you have to write your own code in codebehind.If you can provide your storedprocedure may be I can help more.



To check one radio try this


    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}









oned_gk



To check one radio try this
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}







Thank you, this is work,


for update rows how i do? in gridview 



I want "picid" of selected row (radiobutton checked=true) = 1 and other row shown in gridview => picid=0,


please help me,



I want try this, but thi is not work:








 





and:


        If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
For Each row As GridView In GridView1.Rows
Dim constr As String = ConfigurationManager.ConnectionStrings("starfairConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("firpicup1", con)
cmd.CommandType = CommandType.StoredProcedure
Dim RowIndex As Integer = Convert.ToInt32(e.CommandArgument)
cmd.Parameters.Add(New SqlParameter("@picid", TextBox4.Text))
Dim rb As RadioButton = DirectCast(row.FindControl("RadioButton1"), RadioButton)
cmd.Parameters.Add(New SqlParameter("@main1", rb.Checked))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
Next







[RESOLVED] Radiobutton datakey in gridview


Hi,


I have a radiobutton in gridview:








 





but


   If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
end if

not work, but this code worked for :


 

but for radiobutton not work, please help me.









Add attribute of gridview onRowCommand="GridView1_RowCommand"



protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

{


         if(e.CommandName == "Select")


         {


               //Write your code here


         }


}





This code worked for linkbutton. For radiobutton this code not work.

I think require CommandArgument in radiobutton,


How to add this radiobutton?



Instead of firing rowommand event, use radioButton's selectedIndexChanged method where u can get selected value and  you can directly assign that value to textbox...


Just change your approach if possible...


[RESOLVED] RadioButton in Gridview


Hi,


I have table whit field: "picid" , and a gridview whit radiobutton:








 




In gridview, i want only one radiobutton is checked,


and when click the other radiobutton, current record "picid" field is 1 and other records picid is 0, (table Update)


I want in blew code:


update pic set picid=1 where radiobutton selected and other records of gridviwe --> picid=0


If e.CommandName = "select" Then
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("picup", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@picid", e.CommandArgument.ToString()))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
End If

How i do?


Thank you for your attention...





anuj_koundal



Use groupname property to group them.

Refrence: http://www.codingfusion.com/Post/Write-a-program-to-list-your-favourate-colors-usin







This is not solve my problem,


i use only one radiobutton in gridview ... and  ...



you have to fire SelectCommand from your grid, to properly catch the grid-selection changed event. and you should use GroupName properly as well,




Please send me more code for this, if possible. 1. I want only 1 radiobutton checked in every time. 2. I want when radiobutton checked: picid field of current record set =1 and picid filed other records set=0

For your first requirement only one radio button is checked : 







groupname="abc" ID="RadioButton1" runat="server" Checked='<%# Eval("picid") %>' />
 




For your second requirement you have to write your own code in codebehind.If you can provide your storedprocedure may be I can help more.



To check one radio try this


    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}









oned_gk



To check one radio try this
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}







Thank you, this is work,


for update rows how i do? in gridview 



I want "picid" of selected row (radiobutton checked=true) = 1 and other row shown in gridview => picid=0,


please help me,



I want try this, but thi is not work:








 





and:


        If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
For Each row As GridView In GridView1.Rows
Dim constr As String = ConfigurationManager.ConnectionStrings("starfairConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("firpicup1", con)
cmd.CommandType = CommandType.StoredProcedure
Dim RowIndex As Integer = Convert.ToInt32(e.CommandArgument)
cmd.Parameters.Add(New SqlParameter("@picid", TextBox4.Text))
Dim rb As RadioButton = DirectCast(row.FindControl("RadioButton1"), RadioButton)
cmd.Parameters.Add(New SqlParameter("@main1", rb.Checked))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
Next







[RESOLVED] Radiobutton datakey in gridview


Hi,


I have a radiobutton in gridview:








 





but


   If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
end if

not work, but this code worked for :


 

but for radiobutton not work, please help me.









Add attribute of gridview onRowCommand="GridView1_RowCommand"



protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

{


         if(e.CommandName == "Select")


         {


               //Write your code here


         }


}





This code worked for linkbutton. For radiobutton this code not work.

I think require CommandArgument in radiobutton,


How to add this radiobutton?



Instead of firing rowommand event, use radioButton's selectedIndexChanged method where u can get selected value and  you can directly assign that value to textbox...


Just change your approach if possible...


[RESOLVED] RadioButton in Gridview


Hi,


I have table whit field: "picid" , and a gridview whit radiobutton:








 




In gridview, i want only one radiobutton is checked,


and when click the other radiobutton, current record "picid" field is 1 and other records picid is 0, (table Update)


I want in blew code:


update pic set picid=1 where radiobutton selected and other records of gridviwe --> picid=0


If e.CommandName = "select" Then
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("picup", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@picid", e.CommandArgument.ToString()))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
End If

How i do?


Thank you for your attention...





anuj_koundal



Use groupname property to group them.

Refrence: http://www.codingfusion.com/Post/Write-a-program-to-list-your-favourate-colors-usin







This is not solve my problem,


i use only one radiobutton in gridview ... and  ...



you have to fire SelectCommand from your grid, to properly catch the grid-selection changed event. and you should use GroupName properly as well,




Please send me more code for this, if possible. 1. I want only 1 radiobutton checked in every time. 2. I want when radiobutton checked: picid field of current record set =1 and picid filed other records set=0

For your first requirement only one radio button is checked : 







groupname="abc" ID="RadioButton1" runat="server" Checked='<%# Eval("picid") %>' />
 




For your second requirement you have to write your own code in codebehind.If you can provide your storedprocedure may be I can help more.



To check one radio try this


    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}









oned_gk



To check one radio try this
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rb = (RadioButton)row.FindControl("RadioButton1");
rb.Checked = false;
}
RadioButton currentrb = (RadioButton)sender;
currentrb.Checked = true;
}







Thank you, this is work,


for update rows how i do? in gridview 



I want "picid" of selected row (radiobutton checked=true) = 1 and other row shown in gridview => picid=0,


please help me,



I want try this, but thi is not work:








 





and:


        If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
For Each row As GridView In GridView1.Rows
Dim constr As String = ConfigurationManager.ConnectionStrings("starfairConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("firpicup1", con)
cmd.CommandType = CommandType.StoredProcedure
Dim RowIndex As Integer = Convert.ToInt32(e.CommandArgument)
cmd.Parameters.Add(New SqlParameter("@picid", TextBox4.Text))
Dim rb As RadioButton = DirectCast(row.FindControl("RadioButton1"), RadioButton)
cmd.Parameters.Add(New SqlParameter("@main1", rb.Checked))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
Next







[RESOLVED] Radiobutton datakey in gridview


Hi,


I have a radiobutton in gridview:








 





but


   If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()
end if

not work, but this code worked for :


 

but for radiobutton not work, please help me.









Add attribute of gridview onRowCommand="GridView1_RowCommand"



protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

{


         if(e.CommandName == "Select")


         {


               //Write your code here


         }


}





This code worked for linkbutton. For radiobutton this code not work.

I think require CommandArgument in radiobutton,


How to add this radiobutton?



Instead of firing rowommand event, use radioButton's selectedIndexChanged method where u can get selected value and  you can directly assign that value to textbox...


Just change your approach if possible...


[RESOLVED] Gridview Update whit radiobutton


Hi, 


I Have a gridview :









 





and:


        If e.CommandName = "select" Then
TextBox4.Text = e.CommandArgument.ToString()


For Each row As GridViewRow In GridView1.Rows

Dim constr As String = ConfigurationManager.ConnectionStrings("starfairConnectionString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("firpicup1", con)
cmd.CommandType = CommandType.StoredProcedure
Dim RowIndex As Integer = Convert.ToInt32(e.CommandArgument)
cmd.Parameters.Add(New SqlParameter("@picid", TextBox4.Text))
Dim rb As RadioButton = DirectCast(row.FindControl("RadioButton1"), RadioButton)
cmd.Parameters.Add(New SqlParameter("@main1", "1"))
Dim dr As SqlDataReader
con.Open()
dr = cmd.ExecuteReader()
GridView1.DataBind()
Next
End If

I want when radio button checked, current row "main1" field =1 and in the other rows"main1" field =0,


how to change the above code?












No one to help me?

hi,


You can't use rowcommand event in radiobutton . and we also can't use checkedchange event .Even if defind groupname of this radiobutton , but in different row the name in html code of this radiobutton is different .you can press F12 to observed the radiobutton's
name .you will get such as the below :


name="GridView2$ctl02$abc" value="RadioButton1" />

name="GridView2$ctl03$abc" value="RadioButton1" />

Because the name is different ,so the checkedchanged event can't trigger .


to you purpose .I suggest use linkbutton or use checkbox .


Hope this helps


 


 


 



Thanks. For checkbox how i do?

hi,


This tutorial looks at how to add a column of check boxes to a GridView control to provide the user with an intuitive way of selecting multiple rows of the GridView.


http://www.asp.net/web-forms/tutorials/data-access/enhancing-the-gridview/adding-a-gridview-column-of-checkboxes-cs


if you need to change row value or something else by checkbox changed event  , you can use Jquery ajax  to trigger webmethod in webmethod .


http://stackoverflow.com/questions/348689/jquery-ajax-with-asp-net-webmethod-returning-entire-page


Hope this helps