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

Below is my aspx code for detail view.
My problem is i have a value in cusid field but it is coming as null.
Could you please correct me where i am going wrong.
ASP.NET
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="customerds1" Height="178px"
                                                        Width="438px" AutoGenerateRows="False" CellPadding="4" DataKeyNames="CusId" ForeColor="#333333"
                                                        GridLines="None" OnPageIndexChanging="DetailsView1_PageIndexChanging" AutoGenerateDeleteButton="True"
                                                        AutoGenerateEditButton="True" Visible="False">
                                                        <footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
                                                        <commandrowstyle backcolor="#E2DED6" font-bold="True" />
                                                        <rowstyle backcolor="#F7F6F3" forecolor="#333333" />
                                                        <fieldheaderstyle backcolor="#E9ECF1" font-bold="True" />
                                                        <pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center" />
                                                        <fields>
                                                            <asp:TemplateField HeaderText="Customer ID:" SortExpression="CusId">
                                                                <edititemtemplate>
                                                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("CusId") %>'>
                                                                </edititemtemplate>
                                                                <insertitemtemplate>
                                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CusId") %>'>
                                                                </insertitemtemplate>
                                                                <itemtemplate>
                                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("CusId") %>'>
                                                                </itemtemplate>
                                                            
                                                            <asp:BoundField DataField="CompName" HeaderText="CompanyName:" SortExpression="CompName" />
                                                            <asp:BoundField DataField="CompAdd" HeaderText="CompanyAdd:" SortExpression="CompAdd" />
                                                            <asp:BoundField DataField="Tel" HeaderText="Tel:" SortExpression="Tel" />
                                                            <asp:BoundField DataField="Fax" HeaderText="Fax:" SortExpression="Fax" />
                                                            <asp:BoundField DataField="ContPerson" HeaderText="Contact Person:" SortExpression="ContPerson" />
                                                            <asp:TemplateField HeaderText="Sales Person:" SortExpression="SalesPerson">
                                                                <edititemtemplate>
                                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("SalesPerson") %>'>
                                                                </edititemtemplate>
                                                                <insertitemtemplate>
                                                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("SalesPerson") %>'>
                                                                </insertitemtemplate>
                                                                <itemtemplate>
                                                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("SalesPerson") %>'>
                                                                </itemtemplate>
                                                            
                                                        </fields>
                                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                        <editrowstyle backcolor="#999999" />
                                                        <alternatingrowstyle backcolor="White" forecolor="#284775" />


cs code

C#
string cusId = DetailsView1.Rows[0].Cells[1].Text;
Posted
Updated 21-Nov-11 4:18am
v2
Comments
_Tushar Patil 22-Nov-11 5:02am    
Check Whether you were accessing value Before Binding Data to Details View...
Lancy.net 22-Nov-11 8:14am    
Thanks for your reply

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