Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > error ครับ Unable to cast object of type 'System.Int32' to type 'System.String'.



 

error ครับ Unable to cast object of type 'System.Int32' to type 'System.String'.

 



Topic : 096266



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์




error ครับ Unable to cast object of type 'System.Int32' to type 'System.String'.
Code (C#)
        Label lblAgen = (Label)(e.Row.FindControl("lblAgen"));
        if (lblAgen != null)
		{
            lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");
		}




Tag : .NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-06-07 19:44:52 By : Kaen17 View : 3442 Reply : 28
 

 

No. 1



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


อย่างนี้จะได้ไหม
lblAgen.Text = e.Row.DataItem("AgenciesID").ToString();







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-07 21:14:15 By : watcharop
 


 

No. 2



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้ครับ ผมลองใช้ Code (C#)
lblAgen.Text = e.Row.DataItemIndex.ToString("AgenciesID");

มันขึ้นเเต่คำว่า AgenciesID ทุกอันเลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-07 21:36:20 By : Kaen17
 

 

No. 3



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


แบบนี้ Error หรือครับ
lblAgen.Text = e.Row.DataItem("AgenciesID").ToString();


เห็นคุณเขียนไม่เหมือนที่ผมเขียน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-07 23:44:39 By : watcharop
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 08:27:39 By : mr.win
 


 

No. 5



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


ใช่ครับ ใช้เเบบ Code (C#)
lblAgen.Text = e.Row.DataItem("AgenciesID").ToString();


ee
error ครับ ผมเลยลองเปลี่ยนดูครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 09:13:17 By : Kaen17
 


 

No. 6



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


โค้ดนี้มันอยู่ใน Event ไหนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 14:48:09 By : watcharop
 


 

No. 7



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


อยุ่ใในนี้ครับบ
Code (C#)
void myGridView_RowDataBound(Object s, GridViewRowEventArgs e) 
	{
        Label lblAgen = (Label)(e.Row.FindControl("lblAgen"));
        if (lblAgen != null)
		{
            lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");    
		}

        Label lblName = (Label)(e.Row.FindControl("lblName"));
		if (lblName != null)
		{
            lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesName");
		}
}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 15:58:02 By : Kaen17
 


 

No. 8



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


มันมีฟิล์ด AgenciesName จริงๆ เหรอครับ


ประวัติการแก้ไข
2013-06-08 16:19:58
2013-06-08 16:22:49
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 16:18:45 By : watcharop
 


 

No. 9



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


มีครับ ใน DB มี AgenciesID เก็บเป็น int ให้ รัน Auto ครับ ส่วน AgenciesName เก็บจากการบันทึกครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 16:47:54 By : Kaen17
 


 

No. 10

Guest


Code (C#)
       //Pass Parameter Between Pages.
        protected void Button2_Click(object sender, EventArgs e)
        {
            string s = "lbluser.Text, lbltype.Text, txttotal.Text";
            Page.Items.Add("xxx", s);
            Response.Redirect("finish.aspx");
        }



Code (C#)
       //Get Parameter Between Pages.
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((string)Page.Items["xxx"] != null)
            {
                Response.Write("How old are you?");
            }
        }

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-08 17:00:59 By : ผ่านมาพอดี
 


 

No. 11



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


ยังไม่ได้เลยครับ error ครับ Unable to cast object of type 'System.Int32' to type 'System.String'. error ที่ Code (C#)
lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");    

Code (C#)
void myGridView_RowDataBound(Object s, GridViewRowEventArgs e) 
	{
        Label lblAgen = (Label)(e.Row.FindControl("lblAgen"));
        if (lblAgen != null)
		{
            lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");    
		}

        Label lblName = (Label)(e.Row.FindControl("lblName"));
		if (lblName != null)
		{
            lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesName");
		}
}




ประวัติการแก้ไข
2013-06-09 07:42:01
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 07:41:18 By : Kaen17
 


 

No. 12



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


ตรวจสอบว่า DataItem มีข้อมูลไหม
void myGridView_RowDataBound(Object s, GridViewRowEventArgs e) 
	{
If(e.Row.DataItem) {
        Label lblAgen = (Label)(e.Row.FindControl("lblAgen"));
        if (lblAgen != null)
		{
            lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");    
		}

        Label lblName = (Label)(e.Row.FindControl("lblName"));
		if (lblName != null)
		{
            lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesName");
		}
}
}




แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 11:51:14 By : watcharop
 


 

No. 13



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


เอาหน้าโค้ดหน้า .aspx มาให้ดูหน่อย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 11:53:16 By : watcharop
 


 

No. 14



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


นี่ครับ
Code (C#)
 <%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="listAgenciesAdmin.aspx.cs" Inherits="Project56.listAgenciesAdmin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style8
        {
            text-align: center;
        }
        .style9
        {
            font-weight: bold;
            font-size: x-large;
        }
        .style11
    {
        text-align: center;
        width: 124px;
    }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <p>
        <table cellpadding="0" cellspacing="0" class="style5">
            <tr>
                <td class="style9" colspan="2">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                    ตารางข้อมูลหน่วยงานผู้บริหาร&nbsp;
                    <br />
                </td>
            </tr>
            <tr>
                <td class="style8" colspan="2">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
                    <asp:Button ID="Button1" runat="server" PostBackUrl="~/Addagencies.aspx" 
                        style="font-size: small" Text="เพิ่มหน่วยงาน" />
                </td>
            </tr>
            <tr>
                <td class="style11">
                    &nbsp;</td>
                <td style="text-align: right">

<script runat="server">
    void Page_Load(object sender,EventArgs e)		
	{
		if(!Page.IsPostBack)
		{
			BindData();
		}
    }

	void BindData()
	{
        SqlConnection objConn = new SqlConnection();
		SqlCommand objCmd = new SqlCommand();
        SqlDataAdapter dtAdapter = new SqlDataAdapter();
		DataSet ds = new DataSet();
		String strConnString,strSQL;

		strConnString = "Server=localhost;UID=sa;PASSWORD=12345;database=mydatabase;Max Pool Size=400;Connect Timeout=600;";
        strSQL = "SELECT * FROM Agencies";

		objConn.ConnectionString = strConnString;
		objCmd.Connection = objConn;
		objCmd.CommandText = strSQL	;
		objCmd.CommandType = CommandType.Text;

		dtAdapter.SelectCommand = objCmd;
		dtAdapter.Fill(ds);

		myGridView.DataSource = ds;
		myGridView.DataBind();

		dtAdapter = null;		
		objConn.Close();
		objConn = null;

	}

	void myGridView_RowDataBound(Object s, GridViewRowEventArgs e) 
	{
        Label lblAgen = (Label)(e.Row.FindControl("lblAgen"));
        if (lblAgen != null)
		{
            lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");    
		}

        Label lblName = (Label)(e.Row.FindControl("lblName"));
		if (lblName != null)
		{
            lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesName");
		}

        HyperLink hplDetail = (HyperLink)e.Row.FindControl("hplDetail");
        if ((hplDetail != null))
        {
            hplDetail.NavigateUrl = "JavaScript:void(0);";
            hplDetail.Attributes.Add("OnClick", "JavaScript:OpenPopup('popupDetailSchedule.aspx?AgenciesID=" + e.Row.DataItemIndex.ToString("AgenciesID").ToString() + "');");
        }
        HyperLink hplEdit = (HyperLink)(e.Row.FindControl("hplEdit"));
        if (hplEdit != null)
        {
            hplEdit.NavigateUrl = "editmemberAdmin.aspx?AgenciesID=" + e.Row.DataItemIndex.ToString("AgenciesID").ToString();
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
            l.Attributes.Add("onclick", "javascript:return " + "confirm('คุณต้องการลบ รายชื่อ : " +
            DataBinder.Eval(e.Row.DataItem, "AgenciesID") + "')");
        }
	}
	
	void ShowPageCommand(Object s, GridViewPageEventArgs e)
	{
		myGridView.PageIndex = e.NewPageIndex;
		BindData();
	}
	
</script>

</script>
    <script type="text/javascript">
        function OpenPopup(url) {
            popup = window.open(url, "mypopup", "location=1,status=1,scrollbars=1,width=700,height=700");
            popup.moveTo(0, 0);
        }
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - SQL Server</title>
</head>
<body>
	<form id="form1">
		<asp:GridView id="myGridView" PageSize="20" 
		OnPageIndexChanging="ShowPageCommand"
		onRowDataBound="myGridView_RowDataBound"
		AutoGenerateColumns="False" AllowPaging="True" runat="server" BackColor="White" 
            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            style="text-align: center; font-size: small">
		    <FooterStyle BackColor="White" ForeColor="#000066" />
		<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White"></HeaderStyle>

		<Columns>

		<asp:TemplateField HeaderText="รหัสหน่วยงาน">
			<ItemTemplate>
				<asp:Label id="lblAgen" runat="server"></asp:Label>
			</ItemTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="รายชื่อหน่วยงาน">
			<ItemTemplate>
				<asp:Label id="lblName" runat="server"></asp:Label>
			</ItemTemplate>
		</asp:TemplateField>
                   <asp:TemplateField HeaderText="รายละเอียด">
		        <ItemTemplate>
                    <asp:HyperLink ID="hplDetail" runat="server"><img src="images/view_detailed.png" width="18" height="18"></asp:HyperLink>
		        </ItemTemplate>
	        </asp:TemplateField>
	    <asp:TemplateField HeaderText="แก้ไข">
		        <ItemTemplate>
                    <asp:HyperLink ID="hplEdit" runat="server"><img src="images/edit.png" width="18" height="18"></asp:HyperLink>
		        </ItemTemplate>
	        </asp:TemplateField>
              <asp:TemplateField HeaderText="ลบ">
		        <ItemTemplate>
                    <asp:LinkButton id="LinkButton1" CommandName="Delete" runat="server"><img src="images/deletered.png" width="18" height="18"></asp:LinkButton>
		        </ItemTemplate>
	        </asp:TemplateField>

		</Columns>

		    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />

		</asp:GridView>		
	</form>
</body>
</html>&nbsp;</td>
            </tr>
            <tr>
                <td class="style11">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
        &nbsp;</p>
</asp:Content>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 12:08:50 By : Kaen17
 


 

No. 15



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


ผิดที่ BindData รึเปล่านะ เปลี่ยนจาก DataSet เป็น DataTable
void BindData()
	{
        SqlConnection objConn = new SqlConnection();
		SqlCommand objCmd = new SqlCommand();
        SqlDataAdapter dtAdapter = new SqlDataAdapter();
		DataTable dt = new DataTable();
		String strConnString,strSQL;

		strConnString = "Server=localhost;UID=sa;PASSWORD=12345;database=mydatabase;Max Pool Size=400;Connect Timeout=600;";
        strSQL = "SELECT * FROM Agencies";

		objConn.ConnectionString = strConnString;
		objCmd.Connection = objConn;
		objCmd.CommandText = strSQL	;
		objCmd.CommandType = CommandType.Text;

		dtAdapter.SelectCommand = objCmd;
		dtAdapter.Fill(dt);

		myGridView.DataSource = dt;
		myGridView.DataBind();

		dtAdapter = null;		
		objConn.Close();
		objConn = null;

	}


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 12:38:02 By : watcharop
 


 

No. 16



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


เปลี่ยนเเล้วไม่ได้เหมือนเดิมครับ ><
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 12:59:15 By : Kaen17
 


 

No. 17



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


งั้นลอง AutoGenerateColumns ว่ามีข้อมูลขึ้นมาไหม
<asp:GridView id="myGridView" PageSize="20" 
		AutoGenerateColumns="True" AllowPaging="True" runat="server" BackColor="White" 
            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            style="text-align: center; font-size: small">


		</asp:GridView>		


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 13:15:26 By : watcharop
 


 

No. 18



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้เหมือนเดิมครับ

มันเกี่ยวกับ ที่ใน Database เก็บ AgenciesID เป็น int ให้มัน run auto ไหมครับ ? คือถ้า เก็บเป็น varchar เเละ ไม่ให้ run auto ไม่มีปัญหาครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 13:24:46 By : Kaen17
 


 

No. 19



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


Error ที่ตรงไหนล่ะ
ถ้าคุณเปลี่ยนโค้ดตามข้อ 17
มันไม่ควร Error เหมือนเดิมนะครับ
ไม่งั้นก็เอา Event RowDataBound ออกไปก่อน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 13:28:30 By : watcharop
 


 

No. 20



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


อ่อ ข้อมูลาครับ ขึ้นหมดครับ เเต่ error เเบบนี้ครับ
หห
กดไปหน้า 2 error ครับ

เเละ พวก hpl ที่กดไป ลบ-เเก้ไข-ลายละเอียด ไปอยู่ข้างล่างขวาครับ
ฟฟฟฟ


ประวัติการแก้ไข
2013-06-09 13:44:31
2013-06-09 13:45:18
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 13:44:03 By : Kaen17
 


 

No. 21



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


ยอมล่ะ
ดูตัวอย่างของเว็บนี้ล่ะกัน
เข้าใจว่า TC Admin ทำไว้อยู่บ้างนะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 14:36:03 By : watcharop
 


 

No. 22



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


ครับ ขอบคุณมากครับ
ที่มาช่วยตอบปัญหาเล็ก ๆของผม เดี๋ยวผมไม่เอา AgenciesID มา
เอา เเต่ AgenciesName พอครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 14:55:38 By : Kaen17
 


 

No. 23



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


ถ้าคุณหมายถึง AgenciesName ไม่มีปัญหา มีปัญหาแต่ AgenciesID ให้ลองแบบ
lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID","{0}");  

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 15:01:45 By : watcharop
 


 

No. 24



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


ได้เฉยเลยครับ >< ขอบคุณมากครับ :)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 15:27:13 By : Kaen17
 


 

No. 25



โพสกระทู้ ( 1,348 )
บทความ ( 1 )



สถานะออฟไลน์


ถ้าอย่างนั้น พึงระวังว่าหาก AgenciesName เป็นค่าว่าง (Null) ถ้าโค้ดของคุณไม่ใส่ {0} ก็น่าจะ Error ได้ เพราะฉะนั้นควรใส่ไว้ ยกเว้นคุณได้ตั้งกฎควบคุมตอนบันทึกแล้ว
lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesName","{0}");  

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 15:50:20 By : watcharop
 


 

No. 26

Guest


จากหัวข้อของคำถาม เป็นข้อสังเกตุนะครับ


Error
lblAgen.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesID");

*****

Change To : lblAgen.Text = DataBinder.Eval(e.Row.DataItem, "AgenciesID").ToString();
OR
Change To : lblAgen.Text = (int)DataBinder.Eval(e.Row.DataItem, "AgenciesID").ToString();
OR
Change To : lblAgen.Text = Convert.ToString((int)DataBinder.Eval(e.Row.DataItem, "AgenciesID"));


*****
และตาม #NO 25 ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 16:06:45 By : ผ่านมา
 


 

No. 27



โพสกระทู้ ( 231 )
บทความ ( 0 )



สถานะออฟไลน์


อ่อ ขอบคุณมากครับ ได้ความรู้มากครับ ผมเพิ่งลองศึกษาครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 16:45:26 By : Kaen17
 


 

No. 28

Guest


ตอบความคิดเห็นที่ : 25 เขียนโดย : watcharop เมื่อวันที่ 2013-06-09 15:50:20
รายละเอียดของการตอบ ::
A. lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "AgenciesName","{0}");


B. lblName.Text = string.Format("{0}", DataBinder.Eval(e.Row.DataItem, "AgenciesName"));

A = B (A & B convert null to String.Empty)

ปกติผมใช้แบบ B ครับ ผมก็พึ่งรู้เหมือนกันว่ามันเขียนแบบ A. ได้ (กลับหัวกลับหาง)

string testString = string.Format("{0}{1}{2}", "Value1", "Value2", "Value3"); // Result Value1Value2Value3
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-09 16:54:08 By : ผ่านมา
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : error ครับ Unable to cast object of type 'System.Int32' to type 'System.String'.
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่