Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 19, 2013 06:48 AM by mai_mai
Member
5 Points
40 Posts
Jan 16, 2013 12:05 PM|LINK
how to get values from detailesview while it is in read only mood!
All-Star
127011 Points
17934 Posts
MVP
Jan 16, 2013 12:36 PM|LINK
try like this:
protected void DetailsView1_DataBound(object sender, EventArgs e) { if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly) { Label lbl = (Label) DetailsView1.FindControl("YourLabelID"); } }
118619 Points
18779 Posts
Jan 18, 2013 12:35 AM|LINK
vinz Label lbl = (Label) DetailsView1.FindControl("YourLabelID");
Label lbl = (Label) DetailsView1.FindControl("YourLabelID");
Hi,
Maybe we should use something like DetailsView1.Rows[0-based index].FindControl instead of directly FindControl.
For direct FindControl won't find the nested controls inside the DetailsViewRow.
Now we can see the reflected codes;)
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), WebSysDescription("DetailsView_Rows")] public virtual DetailsViewRowCollection Rows { get { if (this._rowsCollection == null) { if (this._rowsArray == null) { this.EnsureChildControls(); } if (this._rowsArray == null) { this._rowsArray = new ArrayList(); } this._rowsCollection = new DetailsViewRowCollection(this._rowsArray); } return this._rowsCollection; } }
Correct me if I take you wrongly;)
Jan 18, 2013 01:30 PM|LINK
Decker Dong - MSFT Maybe we should use something like DetailsView1.Rows[0-based index].FindControl instead of directly FindControl.
I agree.
Jan 19, 2013 05:50 AM|LINK
i try it but it not work
this is my deatilsview:
<asp:DetailsView ID="Sort_DetailsView" runat="server" AllowPaging="True" AutoGenerateRows="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataKeyNames="DI" DataSourceID="SortDetailes_SqlDataSource" ForeColor="Black" Height="50px" Width="546px"> <FooterStyle BackColor="#CCCCCC" /> <RowStyle BackColor="White" /> <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" /> <Fields> <asp:BoundField DataField="DI" HeaderText="DI" ReadOnly="True" SortExpression="DI" /> <asp:BoundField DataField="Cost_Code" HeaderText="Cost Code" SortExpression="Cost_Code" /> <asp:BoundField DataField="N_Time" HeaderText="Need Time" SortExpression="N_Time" /> <asp:BoundField DataField="Item" HeaderText="Item" SortExpression="Item" /> <asp:BoundField DataField="Rcom" HeaderText="Request Comment" SortExpression="Rcom" /> <asp:BoundField DataField="Requester_BN" HeaderText="Planner" SortExpression="Requester_BN" /> <asp:BoundField DataField="Request_Time" HeaderText="Request Time" SortExpression="Request_Time" /> <asp:BoundField DataField="Send_WH_BN" HeaderText="Send Warehouse" SortExpression="Send_WH_BN" /> <asp:BoundField DataField="Send_WH_Time" HeaderText="Send Warehouse Time" SortExpression="Send_WH_Time" /> </Fields> <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /> </asp:DetailsView>
Jan 19, 2013 06:45 AM|LINK
mai_mai mai_mai
According to your situation, I think since you are not using itemTemplate, you have to use DetailsView.Rows[index].Cells[index].Text instead.
Jan 19, 2013 06:48 AM|LINK
Finally i find the solution
dim d as string
d= Sort_DetailsView.Rows(7).Cells(1).Text
mai_mai
Member
5 Points
40 Posts
get value form detailsview issue
Jan 16, 2013 12:05 PM|LINK
how to get values from detailesview while it is in read only mood!
vinz
All-Star
127011 Points
17934 Posts
MVP
Re: get value form detailsview issue
Jan 16, 2013 12:36 PM|LINK
try like this:
protected void DetailsView1_DataBound(object sender, EventArgs e) { if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly) { Label lbl = (Label) DetailsView1.FindControl("YourLabelID"); } }MessageBox Controls for WebForms | Blog | Twitter | Linkedin
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: get value form detailsview issue
Jan 18, 2013 12:35 AM|LINK
Hi,
Maybe we should use something like DetailsView1.Rows[0-based index].FindControl instead of directly FindControl.
For direct FindControl won't find the nested controls inside the DetailsViewRow.
Now we can see the reflected codes;)
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), WebSysDescription("DetailsView_Rows")] public virtual DetailsViewRowCollection Rows { get { if (this._rowsCollection == null) { if (this._rowsArray == null) { this.EnsureChildControls(); } if (this._rowsArray == null) { this._rowsArray = new ArrayList(); } this._rowsCollection = new DetailsViewRowCollection(this._rowsArray); } return this._rowsCollection; } }Correct me if I take you wrongly;)
vinz
All-Star
127011 Points
17934 Posts
MVP
Re: get value form detailsview issue
Jan 18, 2013 01:30 PM|LINK
I agree.
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
mai_mai
Member
5 Points
40 Posts
Re: get value form detailsview issue
Jan 19, 2013 05:50 AM|LINK
i try it but it not work
this is my deatilsview:
<asp:DetailsView ID="Sort_DetailsView" runat="server" AllowPaging="True"
AutoGenerateRows="False" BackColor="#CCCCCC" BorderColor="#999999"
BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2"
DataKeyNames="DI" DataSourceID="SortDetailes_SqlDataSource" ForeColor="Black"
Height="50px" Width="546px">
<FooterStyle BackColor="#CCCCCC" />
<RowStyle BackColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<Fields>
<asp:BoundField DataField="DI" HeaderText="DI" ReadOnly="True"
SortExpression="DI" />
<asp:BoundField DataField="Cost_Code" HeaderText="Cost Code"
SortExpression="Cost_Code" />
<asp:BoundField DataField="N_Time" HeaderText="Need Time"
SortExpression="N_Time" />
<asp:BoundField DataField="Item" HeaderText="Item" SortExpression="Item" />
<asp:BoundField DataField="Rcom" HeaderText="Request Comment"
SortExpression="Rcom" />
<asp:BoundField DataField="Requester_BN" HeaderText="Planner"
SortExpression="Requester_BN" />
<asp:BoundField DataField="Request_Time" HeaderText="Request Time"
SortExpression="Request_Time" />
<asp:BoundField DataField="Send_WH_BN" HeaderText="Send Warehouse"
SortExpression="Send_WH_BN" />
<asp:BoundField DataField="Send_WH_Time" HeaderText="Send Warehouse Time"
SortExpression="Send_WH_Time" />
</Fields>
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
</asp:DetailsView>
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: get value form detailsview issue
Jan 19, 2013 06:45 AM|LINK
Hi,
According to your situation, I think since you are not using itemTemplate, you have to use DetailsView.Rows[index].Cells[index].Text instead.
mai_mai
Member
5 Points
40 Posts
Re: get value form detailsview issue
Jan 19, 2013 06:48 AM|LINK
Finally i find the solution
dim d as string
d= Sort_DetailsView.Rows(7).Cells(1).Text