Wednesday, March 28, 2012

Validating a field in datagrid...

i have this datagrid:
<Columns>
<asp:ButtonColumn Text=">" ButtonType="PushButton" CommandName="Select"></asp:ButtonColumn>
<asp:BoundColumn Visible="False" DataField="AddressTypeId" SortExpression="AddressTypeId" ReadOnly="True" HeaderText="AddressTypeId"></asp:BoundColumn>
<asp:BoundColumn DataField="AddressTypeDesc" SortExpression="AddressTypeDesc" HeaderText="Description"></asp:BoundColumn>
</Columns
And i need to validate the AddressTypeDesc (for not inserting two times the same description) but with the validators i can't do that (i am getting an error).

Does anybody knows how-to?

Thanks inadvance,
Mike.

(Sorry for my bad english)Please if somebody knows!!!

Thanks!
in the update datagrid function you can capture the fields' values and then do reguler if then expressions like so:


<asp:datagrid id="dg"....
<columns>
<ASP:BoundColumn
DataField="RecID"
ReadOnly=True
Visible="False" />
...
</columns>
</asp:datagrid>

in the script...

protected void Update_dg(Object sender, DataGridCommandEventArgs e) {
String RecID = e.Item.Cells[0].Text;
...

if ( RecID == '123' ) {
// do some stuff...
}


Hope this helps.
Thank you, i will try this :)

No comments:

Post a Comment