E
Edward Mitchell
I have a database with text string fields defined by varchar(nnn). When I
request from the user the text from a textbox, I'd like to set the maximum
number of characters in the textbox to the "nnn" that was used in the
varchar(...) statement in the field definition. i.e.
Field1 varchar(25) NOT NULL
and in the .aspx file:
<asp.textbox id=Field1 runat="server" />
I load a dataset and put data in the text box via the following:
DataSet dsInfo = new DataSet();
SqlDataAdapter daRecord
= new SqlDataAdapter("SELECT * FROM Records WHERE RecordID ='"
+ RecordID + "'", SqlConnect);
daRecord.Fill(dsInfo, "Table");
DataTable dtRecord = dsInfo.Tables["Table"];
DataRow drRecord = dtRecord.Rows[0];
textBox1.Text = drRecord["Field1"]
textBox1.MaxLength = ???
My question is how can I set the MaxLength property of the text box?
Somewhere in the depths of the DataSet must be some description of the
schema defining the field in the table. Could someone offer guidance as to
extracting this? Presumably, I should also be able to extract other details
of the schema such as type or nullability.
I could have an array of sizes for each one of the text boxes but it seems
bad programming practice to have the field sizes defined in two completely
different places.
Ed
request from the user the text from a textbox, I'd like to set the maximum
number of characters in the textbox to the "nnn" that was used in the
varchar(...) statement in the field definition. i.e.
Field1 varchar(25) NOT NULL
and in the .aspx file:
<asp.textbox id=Field1 runat="server" />
I load a dataset and put data in the text box via the following:
DataSet dsInfo = new DataSet();
SqlDataAdapter daRecord
= new SqlDataAdapter("SELECT * FROM Records WHERE RecordID ='"
+ RecordID + "'", SqlConnect);
daRecord.Fill(dsInfo, "Table");
DataTable dtRecord = dsInfo.Tables["Table"];
DataRow drRecord = dtRecord.Rows[0];
textBox1.Text = drRecord["Field1"]
textBox1.MaxLength = ???
My question is how can I set the MaxLength property of the text box?
Somewhere in the depths of the DataSet must be some description of the
schema defining the field in the table. Could someone offer guidance as to
extracting this? Presumably, I should also be able to extract other details
of the schema such as type or nullability.
I could have an array of sizes for each one of the text boxes but it seems
bad programming practice to have the field sizes defined in two completely
different places.
Ed