Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 02, 2012 08:50 AM by shwetha.gadde
Member
124 Points
61 Posts
May 02, 2012 05:52 AM|LINK
Gridview binding code
BindGrid()
{
con.Open(); SqlCommand cmd = new SqlCommand("Select AdmissionNo,FullName,RollNo from Student_Full where PresentClass='" + dlClass.SelectedValue + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); con.Close();
}
for this gridview i additionally added Attendence column with radiobutton list but this is not fired with my selection anyone help me?
Contributor
3116 Points
764 Posts
May 02, 2012 06:17 AM|LINK
try
dlClass.SelectedValue.ToString()
May 02, 2012 06:24 AM|LINK
But its not working gridview not accept that radiobutton it will displayes that values as always null
C#.net
May 02, 2012 06:27 AM|LINK
can i see your dropdownlist in aspx page please
May 02, 2012 07:40 AM|LINK
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged" Width="175px"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="DayName" HeaderText="DayName" /> <asp:BoundField DataField="Date" HeaderText="Date" /> <asp:TemplateField HeaderText="Day"> <ItemTemplate> <asp:DropDownList ID="dlDay" runat="server"> <asp:ListItem>Morning</asp:ListItem> <asp:ListItem>Evening</asp:ListItem> <asp:ListItem>Total Day</asp:ListItem></asp:DropDownList> </ItemTemplate> <EditItemTemplate> </EditItemTemplate></asp:TemplateField> <asp:TemplateField HeaderText="DayType"> <ItemTemplate> <asp:DropDownList ID="dlDayType" runat="server" OnSelectedIndexChanged="DayTypeSelectionChanged" AutoPostBack="true"> <asp:ListItem Value="1">WorkingDay</asp:ListItem> <asp:ListItem Value="0">Holiday</asp:ListItem></asp:DropDownList></ItemTemplate></asp:TemplateField> <asp:TemplateField HeaderText="Reason"> <ItemTemplate> <asp:TextBox ID="txtreason" runat="server"></asp:TextBox></ItemTemplate></asp:TemplateField></Columns> <EditRowStyle BackColor="#7C6F57" /> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#E3EAEB" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> </asp:GridView>
May 02, 2012 07:45 AM|LINK
i can't see your dropdown list that called dlclass ,, i know it must be outside the gridview but where is it?
May 02, 2012 08:08 AM|LINK
<asp:DropDownList ID="dlClass" runat="server" AutoPostBack="True" Height="22px" Width="131px"> </asp:DropDownList>
Taht dlclass is used to bind the grid values based on that class name from my table...
It works fine for me..
Problem is in brAttendence this radiobutton is not accepted in my gridview it returns null value...
May 02, 2012 08:42 AM|LINK
when you are binding this dropdown list are you adding values to it?
like
drplist.DataValueField="anything"
if not in your select statment use dlClass.SelectedText
May 02, 2012 08:50 AM|LINK
Yes, I added.
But i bind gridview with 3 columns(AdmissionNo,FullName,RollNo)..
I add Attendence as the additional column this value is not acceptd with my gridview It takes attendance column value as null.
shwetha.gadd...
Member
124 Points
61 Posts
my gridview not accept radio button list
May 02, 2012 05:52 AM|LINK
Gridview binding code
BindGrid()
{
con.Open();
SqlCommand cmd = new SqlCommand("Select AdmissionNo,FullName,RollNo from Student_Full where PresentClass='" + dlClass.SelectedValue + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
for this gridview i additionally added Attendence column with radiobutton list but this is not fired with my selection anyone help me?
AmalO.Abdull...
Contributor
3116 Points
764 Posts
Re: my gridview not accept radio button list
May 02, 2012 06:17 AM|LINK
try
dlClass.SelectedValue.ToString()
shwetha.gadd...
Member
124 Points
61 Posts
Re: my gridview not accept radio button list
May 02, 2012 06:24 AM|LINK
But its not working gridview not accept that radiobutton it will displayes that values as always null
C#.net
AmalO.Abdull...
Contributor
3116 Points
764 Posts
Re: my gridview not accept radio button list
May 02, 2012 06:27 AM|LINK
can i see your dropdownlist in aspx page please
shwetha.gadd...
Member
124 Points
61 Posts
Re: my gridview not accept radio button list
May 02, 2012 07:40 AM|LINK
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged" Width="175px"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="DayName" HeaderText="DayName" /> <asp:BoundField DataField="Date" HeaderText="Date" /> <asp:TemplateField HeaderText="Day"> <ItemTemplate> <asp:DropDownList ID="dlDay" runat="server"> <asp:ListItem>Morning</asp:ListItem> <asp:ListItem>Evening</asp:ListItem> <asp:ListItem>Total Day</asp:ListItem></asp:DropDownList> </ItemTemplate> <EditItemTemplate> </EditItemTemplate></asp:TemplateField> <asp:TemplateField HeaderText="DayType"> <ItemTemplate> <asp:DropDownList ID="dlDayType" runat="server" OnSelectedIndexChanged="DayTypeSelectionChanged" AutoPostBack="true"> <asp:ListItem Value="1">WorkingDay</asp:ListItem> <asp:ListItem Value="0">Holiday</asp:ListItem></asp:DropDownList></ItemTemplate></asp:TemplateField> <asp:TemplateField HeaderText="Reason"> <ItemTemplate> <asp:TextBox ID="txtreason" runat="server"></asp:TextBox></ItemTemplate></asp:TemplateField></Columns> <EditRowStyle BackColor="#7C6F57" /> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#E3EAEB" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> </asp:GridView>AmalO.Abdull...
Contributor
3116 Points
764 Posts
Re: my gridview not accept radio button list
May 02, 2012 07:45 AM|LINK
i can't see your dropdown list that called dlclass ,, i know it must be outside the gridview but where is it?
shwetha.gadd...
Member
124 Points
61 Posts
Re: my gridview not accept radio button list
May 02, 2012 08:08 AM|LINK
<asp:DropDownList ID="dlClass" runat="server" AutoPostBack="True" Height="22px" Width="131px"> </asp:DropDownList>Taht dlclass is used to bind the grid values based on that class name from my table...
It works fine for me..
Problem is in brAttendence this radiobutton is not accepted in my gridview it returns null value...
AmalO.Abdull...
Contributor
3116 Points
764 Posts
Re: my gridview not accept radio button list
May 02, 2012 08:42 AM|LINK
when you are binding this dropdown list are you adding values to it?
like
drplist.DataValueField="anything"
if not in your select statment use dlClass.SelectedText
shwetha.gadd...
Member
124 Points
61 Posts
Re: my gridview not accept radio button list
May 02, 2012 08:50 AM|LINK
Yes, I added.
But i bind gridview with 3 columns(AdmissionNo,FullName,RollNo)..
I add Attendence as the additional column this value is not acceptd with my gridview It takes attendance column value as null.