scropio gurl

scropio gurl

  • NA
  • 147
  • 99.2k

display gridview on button click

Sep 7 2016 5:49 AM
First i try to displaly gridview on pageload so girdveiw succesffully displayed now i try to display when click on button i try below code but grid not visible
Code
  1. DataTable dt = new DataTable();  
  2. public DataTable info(string id)  
  3. try  
  4. {  
  5. Entities2 wr = new Entities2();  
  6. List<spv_Result> sv = wr.spvec(id).ToList();  
  7. dt.Columns.Add("RowNumber", typeof(int));  
  8. foreach (var c in sv)  
  9. {  
  10. dt.Rows.Add(c.RowNumber);  
  11. }  
  12. return dt;  
  13. }  
  14. catch (Exception ex)  
  15. {  
  16. throw new Exception();  
  17. }  
  18.   
  19. }  
  20.   
  21. protected void Button1_Click(object sender, EventArgs e)  
  22. {  
  23. info(id);  
  24. GridView1.DataSource = dt;  
  25. GridView1.DataBind();  
  26.   
  27. }  
there is data in dt but gridview not display
  1. <asp:GridView ID="GridView1" runat="server" class="display nowrap"  
  2. Width="100%" CellPadding="0"  
  3. Font-Names="Verdana" BackColor ="White" BorderColor="#CCCCCC" BorderStyle="None"  
  4. BorderWidth="1px" Font-Size="9pt">  
  5. <FooterStyle BackColor="White" ForeColor="#000066" />  
  6. <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />  
  7. <PagerStyle BackColor="White" ForeColor="#000066" Horizontal />  
  8. <RowStyle ForeColor="#000066" />  
  9. <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />  
  10. <SortedAscendingCellStyle BackColor="#F1F1F1" />  
  11. <SortedAscendingHeaderStyle BackColor="#007DBB" />  
  12. <SortedDescendingCellStyle BackColor="#CAC9C9" />  
  13. <SortedDescendingHeaderStyle BackColor="#00547E" />  
  14. any solution?  

Answers (6)