| Author: greeny_1984 21 Nov 2008 | Member Level: Diamond | Rating:  Points: 4 |
in the same way as above
on submit_click event for (int i = 0; i <= gvExpense.Rows.Count - 1; i++) { RadioButton rd = new RadioButton(); rd = (RadioButton)gvExpense.Rows[i].FindControl("rb1");
if (i == 0) { //get u r record value as shown below
string str = gvExpense.Rows[i].Cells[0].Text;
}
else { rd.Checked = false; }
}
Regards, Greeny_1984
Rate this Response[Excellent/Good/Poor] FRESHERS check this link Need help from me join here
|
| Author: Praveen 21 Nov 2008 | Member Level: Diamond | Rating:  Points: 6 |
if u want to get from database and set the grid radio button value u need to write in gridview1_DatarowBound Event like this
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { RadioButton rb = (RadioButton)(e.Row.FindControl("rb")); if (rb != null) rb.Checked = false; }
and to retrive the satus of radio button at button click
protected void btn1_Click(object sender, EventArgs e) { RadioButton rb = null; foreach (GridViewRow grv in GridView1.Rows) { rb = (RadioButton)(grv.FindControl("rb"));
} }
hope this will help u
|
| Author: Spha 21 Nov 2008 | Member Level: Silver | Rating:  Points: 6 |
this is the code i used guys and when it does'nt return a value of that selected record by default any idea why? here is the code
for (int i = 0; i <= gvExpense.Rows.Count - 1; i++) { RadioButton rd = new RadioButton(); rd = (RadioButton)gvExpense.Rows[i].FindControl("rb1");
if (i == 0) { // rd.Checked = true; string str = gvExpense.Rows[i].Cells[0].Text; lblCode.Text = Convert.ToString(str); dbSE.InsertStudentModule(Convert.ToInt32(123), Convert.ToString(lblCode.Text), "no desc", 1, 1, "PMB", "C", 2009, Convert.ToDateTime(DateTime.Now)); }
else { rd.Checked = false; } }
and this is how my Gridview looks like on Html with the binding
<asp:GridView ID="gvExpense" runat="server" AutoGenerateColumns="False" CellPadding="1" EmptyDataText="No compulsory have been listed" Font-Names="Arial" Font-Size="8pt" ForeColor="DimGray" Height="63px" PageSize="15" Width="525px" OnRowCommand="gvExpense_RowCommand"> <Columns> <asp:TemplateField Visible="False"> <ItemTemplate> <asp:Label ID="lblModCode" runat="server" Text='<%# Eval("DGREDEGREECODE") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField Visible="False"> <ItemTemplate> <asp:Label ID="lblModDesc" runat="server" Text='<%# Eval("DGREDEGREECODE") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="DGREDEGREECODE" HeaderText="DGREDEGREECODE" SortExpression="DGREDEGREECODE" Visible="False" /> <asp:BoundField DataField="Degree" SortExpression="Degree" /> <asp:TemplateField> <ItemTemplate> <asp:RadioButton ID="rb1" runat="server" AutoPostBack="True" OnCheckedChanged="rb1_CheckedChanged" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <a href="javascript:Openpopup('./Popup/Degree/PopUp.aspx?DegreeCode=<%# Eval("DGREDEGREECODE") %>')"> <asp:Label ID="Label12" runat="server" ForeColor="steelblue" Text="Learn More..."></asp:Label> </ItemTemplate> <ItemStyle HorizontalAlign="Right" /> </asp:TemplateField> </Columns> <HeaderStyle BackColor="WhiteSmoke" /> <AlternatingRowStyle BackColor="GhostWhite" /> </asp:GridView>
|
| Author: Legend 21 Nov 2008 | Member Level: Silver | Rating:  Points: 4 |
on submit_click event for (int i = 0; i <= gvExpense.Rows.Count - 1; i++) { RadioButton rd = new RadioButton(); rd = (RadioButton)gvExpense.Rows[i].FindControl("rb1");
if (i == 0) { //get u r record value as shown below
string str = gvExpense.Rows[i].Cells[0].Text;
}
else { rd.Checked = false; }
}
|