Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

GridView_Rowdatabound not firing and when i use select parameter in Sql datasource and also data not bound in the gridview

aspx Page
<asp:GridView ID="GridView1" runat="server" align="center" AllowPaging="True" DataKeyNames="ProjectCode"
                                 AutoGenerateColumns="False" class="tabulardata" DataSourceID="SqlDataSource1" 
                                 HorizontalAlign="Center" Width="100%">
                                 <columns>
                                      <asp:TemplateField HeaderText="Sl.No" ItemStyle-HorizontalAlign="Center" 
                                         ItemStyle-Width="2%">
                                         <itemtemplate>
                                             <asp:Label ID="Sno" runat="server">
                                         </itemtemplate>
                                         <itemstyle horizontalalign="Center" />
                                     
                                     <asp:BoundField HeaderText="Project Code" Visible="true" DataField="ProjectCode"
                                         ItemStyle-HorizontalAlign="center" SortExpression="ProjectCode">
                                     
                                      <asp:BoundField HeaderText="AsstProjLead" DataField="AsstProjLead"
                                         ItemStyle-HorizontalAlign="center" ReadOnly="true" 
                                         SortExpression="AsstProjLead">
                                     
                                 </columns>
                                 <alternatingrowstyle backcolor="#FFF5F5" />   
                     
                 <asp:SqlDataSource ID="SqlDataSource1" runat="server"   
                    ConnectionString="<%$ConnectionStrings:MPP%>"
                   SelectCommand="Select ProjectCode,emp_name+' '+ emp_initial+' - '+emp_number as AsstProjLead
                                  from csAsstProjLeads A inner join 
                                  idpeapp.dbo.view_employee V on V.emp_number=A.AsstProjLead and A.Projectcode=@ProjectCode">  
                  <SelectParameters>
                    <asp:Parameter Name="ProjectCode" Type="String"/>
                  </SelectParameters>

aspx.vb Code
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        Dim sno As New Label
        Dim SrNo As Integer
        If e.Row.RowType = DataControlRowType.DataRow Then
            SrNo = (GridView1.PageIndex + 1) * 10 - 9
            sno = e.Row.FindControl("Sno")
            sno.Text = e.Row.RowIndex + SrNo
            sno.DataBind()
        End If
        If e.Row.RowType = DataControlRowType.DataRow Then
           DataBinder.Eval(e.Row.DataItem, "ProjectNoID")
        End If
End Sub

Pls. help to solve this problem.

Regards,
Ganesh.S
Posted
Updated 28-Jun-11 3:06am
v2

1 solution

Hello,

in xml register onrowdatabound method
OnRowDataBound="GridView1_RowDataBound"

thanks
Sanjeev
 
Share this answer
 
Comments
gani7787 28-Jun-11 9:16am    
No it's not working again. pls. suggest me another soln..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900